Could someone tell me how to read a file's contents into an MS SQL variable using T-SQL?
DECLARE @FileContents VARCHAR(MAX) SELECT @FileContents=BulkColumn FROM OPENROWSET(BULK'PathToYourFile.sql',SINGLE_BLOB) x; -- BINARY --FROM OPENROWSET(BULK'PathToYourFile.sql',SINGLE_CLOB) x; -- CHAR
The SQL Server service account needs to have permissions to read the file obviously.
548k questions
547k answers
4 comments
86.3k users