If exists (Select * From dbo.sysobjects Where id = object_id(N'[dbo].[sp_UpdateIsUser]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) Drop Procedure [dbo].[sp_UpdateIsUser] Go create Proc sp_UpdateIsUser @ProgramId int, @Uids varchar(200), @DeleteUids varchar(200) as declare @PID varchar(20) set @PID=Cast(@ProgramId as varchar); Begin Exec(' Update DDASCommandByTC set IsUser=0 where ProgramID =('+@PID+')and Uid not in ('+@Uids+')' ) Exec( 'Update DDASCommandByTC set IsUser=1 where ProgramID=('+@PID+') and Uid in ('+@Uids+')' ) if @DeleteUids <> null Exec( 'Delete from DDASCommandByTC where ProgramID=('+@PID+') and Uid in ('+@DeleteUids+')' ) End Go
@DeleteUids 这个参数我在前台传入的时候有两种情况一种是为空,我传入null,另一种是有值,求指教这样写对不对
你是执行出错还是什么,把
if @DeleteUids <> null这个改为
IF @DeleteUids IS NOT NULL 来判断吧
执行的时候没错,就是最后那条删除的语句没效果
@阿耒: 那你改成IS NOT NULL 试下呢
这样应该可以 如果不行的话 可以把条件改写成 if(@DeleteUids!=' ') 而不用null
个人觉得这种可行,没有参数传入就传入空字符串
用IsNUll函数