Hello All.
For some special reasons, my table is created every week with a new week no. Please see attached file or screen shot for details.
I would like to output the content of this table to a .csv file via DTS package but I can't do it because the field name (week) of the table increases every week or changes every new month. In DTS, each field in the table and output field is fixed.
Please advise is there a way round for this. Or beside using DTS package, is there other methods to output the content. I can't change the table structure now.
Thank you in advance for your advise.
Best regardsWithin DTS, you can declare a global variable for the file name or table name. You can then include code in your DTS package to determine the appropriate value at runtime.|||Hello Blindman.
Thank you for your advise. After reading the documentation on global variable, I find them difficult to understand. :S
I have used below instead to output my sql table instead and it works perfect. Once again, thank you.
declare @.output varchar(5000)
SELECT @.output = 'bcp <DB Name>.dbo.<Table Name> out D:\<FileName.csv> -t "," /S<ServerName> /U<ID> /P<Password> /c '
EXEC master..xp_cmdshell @.output
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment