Create table name dynamically in SQL server

Write this query and get table name  append with current date

CREATE proc createtable
as 
begin 
DECLARE @SQLString NVARCHAR(MAX) 
SET @SQLString = 'CREATE TABLE Tab_'+convert(varchar,getdate(),112) + '( id bigint,name varchar(200))' 
 EXEC sp_executesql @SQLString 
 end

output :

t.PNG

Ebook Download
View all
Learn
View all