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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 table name

Author  Topic 

neeraj1401
Starting Member

36 Posts

Posted - 2009-01-29 : 06:35:32
I want to create a table which contain the current date in the name like table29012008. Please advice.

Thanks in advance


SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-29 : 06:38:11
This is a path you don't want to enter.
Things will be harder to maintain and code.

Have one table and add the date as a column instead.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

neeraj1401
Starting Member

36 Posts

Posted - 2009-01-29 : 06:45:45
Thanks for quick reply.
I'm working on script which will marge the data of some tables into one table, which will further use as input of other process. I have to maintain the archive of tables as per given format, so i can not change the structure.
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-01-29 : 06:51:27
declare @temp table (val int identity(1,1) primary key, currentdate varchar(32))
insert into @temp
select 'table'+REPLACE(CONVERT(VARCHAR(10), GETDATE(), 3), '/', '') union all
select 'table'+REPLACE(CONVERT(VARCHAR(10), GETDATE()+1, 3), '/', '') union all
select 'table'+REPLACE(CONVERT(VARCHAR(10), GETDATE()+2, 3), '/', '')

select * from @temp
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-29 : 06:53:53
Then you have to create the tables with dynamic SQL.
Good luck and God speed...



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2009-01-29 : 10:14:43
Yeah, good luck with that.
And good luck to the guy who comes along three months after you leave and has to figure out why it suddenly stopped working.

________________________________________________
If it is not practically useful, then it is practically useless.
________________________________________________
Go to Top of Page
   

- Advertisement -