How can I create a table daily, whose name was the current date in the yy/mm/dd format plus the algarism to identify the weekday (for example Wednesday = 4), for instance if the query was run on 01/15/2003 (wednesday), the tabelname would be 3_01_15_4 ?Originally posted by cassianorsilva
How can I create a table daily, whose name was the current date in the yy/mm/dd format plus the algarism to identify the weekday (for example Wednesday = 4), for instance if the query was run on 01/15/2003 (wednesday), the tabelname would be 3_01_15_4 ?
declare @.date char(9)
set @.date = substring(convert(char(4),getdate(),121),4,1)+'_'+ substring(convert(char(7),getdate(),121),6,2)+'_'+ substring(convert(char(10),getdate(),121),9,2)
+'_'+cast(DATEPART(dw, GETDATE()) as char(1))|||Thank you !
The table creation is not included on the proceedure above, right ?|||Originally posted by cassianorsilva
Thank you !
The table creation is not included on the proceedure above, right ?
No it's not, once u have the string in the @.date variable, just concatenate that with ur tablename and use that string in ur table creation
says ur final tablename is in a variable @.tablename.
exec('Create table '+@.tablename)
Sumthin around those lines
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment