SQL server 2000存储过程
if exists(select name from sysobjects where name='GetRecord' and type = 'p') drop procedure GetRecordGO
create procedure GetRecord@id int output,;;;--输出p_id和p_path@path nvarchar(255) outputas
select top 1 @id = p_id, @path = p_path from n_project where p_flag = '0'; if(@id > 0) Update n_project set p_flag = '1' where p_id = @idelse begin set @id = 0;;;;--若没有结果则给个默认值,否则直接返回NULL会使程序错误 set @path = ' '--若p_path为NULL,则它也会返回NULL,从而造成程序错误 endif(@path is NULL)begin set @path = ' ';end
if @@error=0 print 'Good'elseprint 'Fail'go
--测试程序declare @idd intdeclare @ppath nvarchar(255)EXEC dbo.GetRecord @idd output,@ppath outputselect '1'=@idd, '2'=@ppathgo
SQL SERVER中,按CTR+0,即可输入空值NULLhttp://blog.csdn.net/gzq400/archive/2007/02/02/1501235.aspx