一个LINQ TO SQL的存储过程的问题
本帖最后由 jbqiu168 于 2013-02-25 14:03:42 编辑
CREATE PROCEDURE [SalesLT].[DeleteCustomer]
@firstName Name,
@lastName Name
AS
BEGIN
SET NOCOUNT ON;
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
declare @customerId int;
declare @addressId int;
declare addressCursor cursor for
select CustomerId,AddressId
from CustomerAddress
where CustomerId in
(
select CustomerId --find this column
from Customer --in this table
where FirstName=@firstName
and LastName=@lastName
);
begin transaction;
open addresssCursor;
fetch next from addressCursor into @customerId,@addressId;
while @@fetch_status=0 begin
delete CustomerAddress where customerId=@customerId
and addressId=@addressId
delete Address where addressId=@addressId;
loop
--一直提示这附近有语法错误就是找不出来! fetch next from addressCursor into @customerId,@addressId;
end;
close addressCursor;
deallocate addressCursor;
delete Customer
where FirstName=@firstName
and LastName=@lastName;
commit;
END
------解决方案--------------------loop --一直提示这附近有语法错误就是找不出来! fetch next from addressCursor into @customerId,@addressId;
需要loop?