CREATE       PROCEDURE Up_Convert
         @strServer VARCHAR(30),
@strDBName  VARCHAR(30)             
AS
DECLARE @strCodetype VARCHAR(30)
DECLARE @SQL nvarchar(500)
declare @@strCodetype varchar(100)

SET NOCOUNT  ON
SET @strCodetype = '' set @SQL = N'SELECT @strCodetype = codetype FROM ' + '['+ @strServer+'].'+@strDBName+'.dbo.syscode WHERE codename= ''scxtquerymenu'')'
-------------------------------------------
execute sp_executesql   @SQL,
@strCodetype output,
@strCodetype = @strCodetype
-------------------------------
SET NOCOUNT  OFF
GO

解决方案 »

  1.   

    CREATE       PROCEDURE Up_Convert
             @strServer VARCHAR(30),
    @strDBName  VARCHAR(30)             
    AS
    DECLARE @strCodetype VARCHAR(30)
    DECLARE @SQL nvarchar(500)
    declare @strCodetype varchar(100)

    SET NOCOUNT  ON
    SET @strCodetype = '' set @SQL = N'SELECT @strCodetype = codetype FROM ' + '['+ @strServer+'].'+@strDBName+'.dbo.syscode WHERE codename= ''scxtquerymenu'')'
    -------------------------------------------
    execute sp_executesql   @SQL,
    @strCodetype output,
    @strCodetype = @strCodetype
    -------------------------------
    SET NOCOUNT  OFF
    GO
      

  2.   

    上面写错了哦
    CREATE       PROCEDURE Up_Convert
             @strServer VARCHAR(30),
    @strDBName  VARCHAR(30)             
    AS
    DECLARE @strCodetype VARCHAR(30)
    DECLARE @SQL nvarchar(500)
    declare @@strCodetype varchar(100)

    SET NOCOUNT  ON
    SET @strCodetype = '' set @SQL = N'SELECT @strCodetype = codetype FROM ' + '['+ @strServer+'].'+@strDBName+'.dbo.syscode WHERE codename= ''scxtquerymenu'')'
    -------------------------------------------
    execute sp_executesql @SQL,
        N'@strCodetype varchar(100) output',
                 @strCodetype = @strCodetype
    -------------------------------
    SET NOCOUNT  OFF
    GO
      

  3.   

    CREATE       PROCEDURE Up_Convert
             @strServer VARCHAR(30),
    @strDBName  VARCHAR(30)             
    AS
    DECLARE @strCodetype VARCHAR(30)
    DECLARE @SQL nvarchar(500)
    declare @strCodetype varchar(100)

    SET NOCOUNT  ON
    SET @strCodetype = '' set @SQL = N'SELECT @strCodetype = codetype FROM ' + '['+ @strServer+'].['+@strDBName+'].dbo.syscode WHERE codename= ''scxtquerymenu'')'
    -------------------------------------------
    execute sp_executesql   @SQL,
    N'@strCodetype output',
    @strCodetype = @strCodetype
    -------------------------------
    SET NOCOUNT  OFF
    GO