首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

SELECT'Return Value' = @return_value,该怎么处理

2012-08-07 
SELECTReturn Value @return_valueSQL codecreate procedure [dbo].[PROC_ZM_INSERT]asbegindeclare i

SELECT'Return Value' = @return_value

SQL code
create procedure [dbo].[PROC_ZM_INSERT]asbegin        declare insert2_cursor cursor         for select             (c.firstName+' '+isnull(c.middleName,'')+' '+c.lastName), a.addressLine1             from [HumanResources].[Employeeaddress] as ea             join [Person].[address] as a on ea.addressid = a.addressid             join [HumanResources].[Employee] as e on ea.employeeid = e.employeeid             join [Person].[contact] as c on e.contactid = c.contactid                declare @name varchar(60), @address varchar(60)        open insert2_cursor        fetch insert2_cursor into @name, @address        while @@fetch_status = 0        begin            begin try                --print @address                declare @num varchar(60)                set @num = substring(@address,1,patindex('% %', @address))                if isnumeric(@num) = 1                    begin                        if convert(int,@num)> 5000                        begin                            --print @name + '-----' + @address + '-insert into'                            insert into tsql_test ([name],[addr],[lastupdatetime],[lastupdateuser],[delflg])                             values (@name, substring(@address, patindex('% %', @address), len(@address)), getdate(), 'ZM', 0)                        end                    end                fetch insert2_cursor into @name, @address            end try            begin catch                fetch insert2_cursor into @name, @address            end catch        end    close insert2_cursor                        deallocate insert2_cursor            end--执行后DECLARE    @return_value intEXEC    @return_value = [dbo].[PROC_ZM_INSERT]SELECT    'Return Value' = @return_valueGO

'Return Value'的值是-6 为什么,我看其他人的代码'Return Value'都=0 为什么我的事-6?

[解决办法]
喝醉了 看得模模糊糊的 帮顶先
[解决办法]
你单独执行这个存储过程看是什么结果呢?
SQL code
create procedure [dbo].[PROC_ZM_INSERT]asbegin        declare insert2_cursor cursor         for select             (c.firstName+' '+isnull(c.middleName,'')+' '+c.lastName), a.addressLine1             from [HumanResources].[Employeeaddress] as ea             join [Person].[address] as a on ea.addressid = a.addressid             join [HumanResources].[Employee] as e on ea.employeeid = e.employeeid             join [Person].[contact] as c on e.contactid = c.contactid                declare @name varchar(60), @address varchar(60)        open insert2_cursor        fetch insert2_cursor into @name, @address        while @@fetch_status = 0        begin            begin try                --print @address                declare @num varchar(60)                set @num = substring(@address,1,patindex('% %', @address))                if isnumeric(@num) = 1                    begin                        if convert(int,@num)> 5000                        begin                            --print @name + '-----' + @address + '-insert into'                            insert into tsql_test ([name],[addr],[lastupdatetime],[lastupdateuser],[delflg])                             values (@name, substring(@address, patindex('% %', @address), len(@address)), getdate(), 'ZM', 0)                        end                    end                fetch insert2_cursor into @name, @address            end try            begin catch                fetch insert2_cursor into @name, @address            end catch        end    close insert2_cursor                        deallocate insert2_cursor            end 

热点排行