sql server - Delete two tables from a variable table in SQL -
i want able use varable table delete records 2 different tables.
i have far
declare @deleted table (card int) insert @deleted select card table1 recordstatus = 4 delete table2 @deleted d table2.actionstring d.card , select convert(varchar(8),today,112) from(select dateadd(year,-1,getdate())as today)aa
sorry if confusing, using sql managment 2005 want able card number table one, check see if date in table 2 greater year if delete record in table 1.
in table 2 not have field card number need statement.
i have error in second part reads,- @deleted d
thank in advance
your second part of statement quite confusing indeed.... you're mixing delete select in clause..... what trying achieve here??
declare @deleted table (card int) insert @deleted select card table1 recordstatus = 4 delete table2 @deleted d table2.actionstring '%' + cast(d.card varchar(20)) + '%' , convert(datetime, table2.date, 112) <= dateadd(year, -1, getdate()) delete table1 @deleted d table1.card = d.card , convert(datetime, table1.date, 112) <= dateadd(year, -1, getdate())
so trying delete rows table2
the table2.actionstring
equal card
column in @deleted
table?? not quite clear.
also : what's date constraint?? field in table2
want check against?? condition - <=
or >=
or what?
Comments
Post a Comment