Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Insert Column in Excel using stored procedure

Author  Topic 

infodemers
Posting Yak Master

183 Posts

Posted - 2011-06-04 : 23:06:54
Hi,

I wish to add a column to cell [A1] in an existing Excel file.
Using a stored procedure.

Any idea?

Thanks!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-06-05 : 03:33:58
you need to use openrowset or bcp

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

infodemers
Posting Yak Master

183 Posts

Posted - 2011-06-07 : 13:27:12
Hi visakh16,
I got it to work using the ActiveX Script I was already running to copy the excel files to my server, before running the Stored Procedure.

Set objexcel = CreateObject("Excel.Application")
objexcel.Workbooks.Open sDestinationFile
Set objsheet = objexcel.ActiveWorkbook.Worksheets(1)
objsheet.Columns("A").EntireColumn.Insert
objExcel.ActiveWorkbook.Save
objExcel.ActiveWorkbook.Close
objExcel.Quit
Set objexcel = Nothing
Set objsheet = Nothing
Go to Top of Page
   

- Advertisement -