This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prototype generate a CSV report file and send an eml file using python | |
# Prerequisites | |
# | |
# Pyodbc | |
# https://github.com/mkleehammer/pyodbc | |
# pip install pyodbc | |
# | |
# This example uses Microsoft SQL Server's pubs sample database | |
# https://github.com/microsoft/sql-server-samples/tree/master/samples/databases/northwind-pubs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prototype to create an eml file using python | |
import os | |
import uuid | |
from email import generator | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.text import MIMEText | |
# where to write the output file | |
directory = "C:\\Users\\Jeremy\Documents\\python\\email-prototype\\temp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prototype python script to query database using pyodbc | |
# Prerequisites | |
# | |
# Pyodbc | |
# https://github.com/mkleehammer/pyodbc | |
# pip install pyodbc | |
# | |
# This example uses Microsoft SQL Server's pubs sample database | |
# https://github.com/microsoft/sql-server-samples/tree/master/samples/databases/northwind-pubs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- use table variable to store list of reserved words | |
DECLARE @reserved TABLE ( | |
Word VARCHAR(255) NOT NULL | |
); | |
INSERT INTO @reserved ( Word ) | |
VALUES | |
('ADD'), | |
('EXISTS'), | |
('PRECISION'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- see: https://msdn.microsoft.com/en-us/library/ms143729.aspx | |
SELECT | |
TABLE_SCHEMA | |
,TABLE_NAME | |
,COLUMN_NAME | |
,DATA_TYPE | |
FROM INFORMATION_SCHEMA.COLUMNS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE master; | |
SELECT | |
DB.name AS DatabaseName | |
, F.type_desc AS FileType | |
, F.size AS [SizeIn8KbPages] | |
, F.physical_name AS [PysicalFileName] | |
FROM sys.databases AS DB | |
INNER JOIN sys.master_files AS F ON ( DB.database_id = F.database_id ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
S.name AS SchemaName | |
,T.name AS TableName | |
FROM sys.tables AS T | |
INNER JOIN sys.schemas AS S ON ( T.schema_id = S.schema_id ) | |
WHERE NOT EXISTS ( | |
SELECT * | |
FROM sys.columns AS C |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
S.name AS SchemaName | |
,T.name AS TableName | |
FROM sys.tables AS T | |
INNER JOIN sys.schemas AS S ON ( T.schema_id = S.schema_id ) | |
WHERE NOT EXISTS ( | |
SELECT * | |
FROM sys.indexes AS I |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE ReportServer; | |
SELECT C.Path | |
FROM dbo.Subscriptions AS S | |
INNER JOIN dbo.Catalog AS C | |
ON ( S.Report_OID = C.ItemID ) | |
WHERE ExtensionSettings LIKE '%[email protected]%' | |
ORDER BY C.Path; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT 'ALTER TABLE ' + QUOTENAME(S.name) + '.' + QUOTENAME(T.name) + ' DROP CONSTRAINT ' + QUOTENAME(FK.name) + ';' | |
FROM sys.foreign_keys AS FK | |
INNER JOIN sys.tables AS T | |
ON ( Fk.parent_object_id = T.object_id ) | |
INNER JOIN sys.schemas AS S | |
ON ( T.schema_id = S.schema_id ) | |
ORDER BY S.name, T.name, FK.name; |
NewerOlder