有两个表A\B
A结构如下:
**************
id | field1
**************
B结构如下:
**************
repid | field1
**************现在想要写一个delete语句,目的是当A.id=B.repid 的时候删除A里的记录
但是现在repid是nvarchar,而id是int型。请问这个语句我该怎么写
declare @i int
set @i=1
while @i<127657
begin
delete from A where A.id in (select repid+0 from istpIDrepeat where repid='@i')
set @i = @i + 1
end上面的写法不对,请问我该怎么样改正,谢谢!
A结构如下:
**************
id | field1
**************
B结构如下:
**************
repid | field1
**************现在想要写一个delete语句,目的是当A.id=B.repid 的时候删除A里的记录
但是现在repid是nvarchar,而id是int型。请问这个语句我该怎么写
declare @i int
set @i=1
while @i<127657
begin
delete from A where A.id in (select repid+0 from istpIDrepeat where repid='@i')
set @i = @i + 1
end上面的写法不对,请问我该怎么样改正,谢谢!
delete from A where id in (select cast(repid as int) from istpIDrepeat)