When you dealing with dynamic SQL or unknown table structure, SQL meta data could help recover the missing information. There are two main system tables which give you such information: dbo.sysobjects dbo.syscolumns Example below shows how to gather column list for specified table. or if you prefer more generic approach Read more…
I am continuing putting some common examples of operations for Microsoft SQL Server. In addition to some of the Date related code snippets published before, there are few more today:
Writing a log, dumping data, looking for file to be used in Bulk insert…
There are many situations when you would want to have access to files from inside your SQL code on Microsoft SQL Server.
Did you know that you actually can do this? No? Check below for code snippets to perform various operations on files. It is presented in form of the functions but you are actually not limited to that
Prerequisites and assumptions
- Your script should have sufficient rights to perform required access to files (not necessarily local).
- Scripting.FileSystemObject should be present at your SQL Server location and accessible.
Check if file exists
Did you ever faced a situation when you need quickly calculate some boundaries of the Date value like First Day of the month, Last Day of the month, etc… in T-SQL? Colegue of mine asked me this question… WOW! What do you know… It is actually very easy if we think Read more…