这妞不错!

会有那么一天...

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
USE [InformationSystem]
GO
/****** Object:  StoredProcedure [dbo].[pro_oper]    Script Date: 05/06/2015 16:07:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:        <Author,,Name>
-- Create date: <Create Date,,>
-- Description:    <把执行的结果赋给变量>
-- =============================================
ALTER PROCEDURE [dbo].[pro_oper]

AS

DECLARE @strSql NVARCHAR(max)
DECLARE @term_code NVARCHAR(100)

SET @strSql=''

    set @strSql='SELECT top 1 @a=term_code FROM jingpai_line.dbo.st_product_plan 
    where 1=1 and line_code=102 and status=2'
    
    --PRINT @strSql
    
    BEGIN TRY
        exec sp_executesql @strSql,N'@a varchar(100) output',@term_code output --把执行的结果赋给变量@term_code   
    END TRY
    BEGIN CATCH

        RETURN -2
    END CATCH

  print @term_code

 

posted on 2015-05-06 16:13  这妞不错  阅读(1300)  评论(0编辑  收藏  举报