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;;;;--若沒有結(jié)果則給個默認值,否則直接返回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
