I have the following t-sql 2012 and I would like to create a backup table by using the where clause. I
want the where clause since I want to limit the number of rows that are in the backup table.
Thus would you show me how to modify the sql listed below so that it will run correctly in sql server management studio?
declare @qry nvarchar(max);
set @qry='SELECT * into ContactLog_'
+ cast(year(getdate()) as varchar(4))
+ cast(month(getdate()) as varchar(2))
+ cast(day(getdate()) as varchar(2))
+ 'FROM ContactLog
+ 'where [module]=''StudentServices''
- and [contactMode] = ''Parent/Guardian''
- and [contactType] = 2
- and text like ''%ss1.org%''
- and text like ''%/letter.aspx%''
- and datetimestamp >= ''2008-08-01 00:00:00.00''