initial commit

This commit is contained in:
2026-08-26 21:08:20 +01:00
commit 8d45a2505b
30 changed files with 990 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
import pyodbc
try:
connection = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=.;DATABASE=SampleDB;Trusted_Connection=yes')
cursor = connection.cursor()
sql_cmd="""create function ufn_get_cus_code (@cus_id int)
returns varchar(50)
as
begin
declare @cus_code varchar(50)
set @cus_code = (select code from tblCustomers where id = @cus_id)
return @cus_code
end;
"""
cursor.execute(sql_cmd)
connection.commit()
print("User defined function successfully created or altered...")
cursor.close()
connection.close()
except pyodbc.Error as ex:
print()
print("exception: ",ex)
cursor.close()
connection.close()
print()
exit()
print()