need to create an excel sheet without any data in it

  • Hi,

    I need to create an empty excel sheet using T-SQL.

    Can any one help me out in this?

    Thanks in advance

  • 1) You can take a look at this link https://www.simple-talk.com/sql/t-sql-programming/sql-server-excel-workbench/

    2) You can create it via SSIS package and execute the package from ssms.

    Igor Micev,My blog: www.igormicev.com

  • I doubt there is an "elegant" way to do this via TSQL.

    You might be better off trying the SQL CLR, I would imagine you could code against the Excel Object Model with it.

  • Here is an outline of a simple method which does not require Excel to be installed:

    1. Copy a blank worksheet on to your SQL Server called YourTemplateWorksheet.XLSX

    2. EXEC xp_cmdshell 'COPY C:\YourTemplateWorksheet.XLSX C:\YourNewWorksheet.XLSX'

    This is over simplified but hopefully you get the idea. You need to run the usual gamut of security issues around xp_cmdshell

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply