dbTalk Databases Forums  

Automatically create table name

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Automatically create table name in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Kris
 
Posts: n/a

Default Automatically create table name - 07-08-2005 , 11:28 AM






Hi All,

I want to rename table automatically .How can i do this ?

from example table name is Customer --> wants to rename every day as

Customer --> Customer_20050708 on next day
Customer --> Customer_20050709

any help ..
Thanks


Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Automatically create table name - 07-09-2005 , 05:14 AM






I am not sure what you want here

1. DTS to do a table rename only?

I presume you would want a Customer table empty afterwards right?

Have you looked at SELECT INTO followed by a TRUNCATE ?

2. You want to have DTS populate a new table everyday which has a name
change?

Simply rename the DestinationObjectName of the DataPump task. If the
structire is the same you're done.

3. You want DTS to create a new instance of the Customer table, named
accordingley and populate that through DTS?

You can issue a CREATE TABLE statement that has been built in an Active
Script task and then change the DestinationObjectName of the DataPump task
to the new object name.


A few options there as I am unsure as to what you actually need.

--



Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.SQLIS.com - You thought DTS was good. here we show you the new stuff.
www.konesans.com - Consultancy from the people who know


"Kris" <Kris (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hi All,

I want to rename table automatically .How can i do this ?

from example table name is Customer --> wants to rename every day as

Customer --> Customer_20050708 on next day
Customer --> Customer_20050709

any help ..
Thanks




Reply With Quote
  #3  
Old   
Jéjé
 
Posts: n/a

Default Re: Automatically create table name - 07-10-2005 , 08:44 AM



the sp_rename stored procedure can help you:
http://msdn.microsoft.com/library/de...ra-rz_3ns5.asp

exec sp_rename 'Customer_20050708', 'Customer_20050709'



"Kris" <Kris (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hi All,

I want to rename table automatically .How can i do this ?

from example table name is Customer --> wants to rename every day as

Customer --> Customer_20050708 on next day
Customer --> Customer_20050709

any help ..
Thanks




Reply With Quote
  #4  
Old   
David Portas
 
Posts: n/a

Default Re: Automatically create table name - 07-11-2005 , 05:27 AM



Why not just add the date as a column with a default of
CURRENT_TIMESTAMP? Much more convenient than creating a table for each
day.

--
David Portas
SQL Server MVP
--


Reply With Quote
  #5  
Old   
Ilin S via SQLMonster.com
 
Posts: n/a

Default Re: Automatically create table name - 07-14-2005 , 03:41 PM



Hi Kris,
You can create ActiveX Script and use something like this:

' To keep history of all files with date attachments to the file name
' Filename format - \\Server\Drive\Folder\Filename_YYYYMMDD.txt
'Start of destination file name
strFilename = "\\Server\Drive\Folder\Filename_"
'Add 4 digit year + 2 digit month + 2 digit day to file name
strFilename = strFilename & Year(Now()) & Right("0" & Month
(Now()),2) & Right("0" & Day(Now()),2)
'Add file extension to file name
strFilename = strFilename & ".txt"

sSourceFile = strFilename
sDestinationFile =strFilename & "_old" & ".txt"
Regards,
Ilin

Kris wrote:
Quote:
Hi All,

I want to rename table automatically .How can i do this ?

from example table name is Customer --> wants to rename every day as

Customer --> Customer_20050708 on next day
Customer --> Customer_20050709

any help ..
Thanks

--
Message posted via http://www.sqlmonster.com


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.