question

SQLTZ avatar image
SQLTZ asked

Need query that will replace only Date part to current date

Need query that will replace only Date part to current date Drop table #table1 select * into # table1 from Main_20170720_table1 Drop table #table2 select * into # table2 from Main_20170720_table2
sqlserver
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
anthony.green avatar image
anthony.green answered
Build yourself a dynamic SQL string and execute it via sp_executesql Something like DECLARE @sql nvarchar(max) SELECT @sql = 'DROP TABLE....... FROM Main_'+CONVERT(VARCHAR(8),CONVERT(DATE,GETDATE()),112)+_table1' exec sp_executesql @sql
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.