Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DTS Package help with naming table

Status
Not open for further replies.

MMichaels

Technical User
Feb 5, 2003
21
US
I am working on a Windows 2000 box with SQL Server 2000. I have a DTS package that I want to create that I want to run the first of every month. The goal I am trying to achieve is that I want it to automatically name the table I am copying with the day before's date. So, if I was running it today, I would want the DTS Package to run and throw a table in my Archive database and name it "member022508", the table is originally called "member". I tried a few things, and with my lack of experience, nothing worked. I tried naming the table member(getdate()), it took it literal... is there a way to do this? Am I being clear?
 
you want to use dynamic sql for this.

Something like

Code:
[COLOR=blue]declare[/color] @sql nvarchar(4000)

[COLOR=blue]set[/color] @sql = [COLOR=red]'select * into member'[/color] + [COLOR=#FF00FF]convert[/color]([COLOR=blue]varchar[/color](10), [COLOR=#FF00FF]getdate[/color](), 112) + [COLOR=red]' from member'[/color]

[COLOR=blue]exec[/color] sp_executesql @sql

Hope this helps,

Alex

[small]----signature below----[/small]
Majority rule don't work in mental institutions

My Crummy Web Page
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top