动态sql查询输入和输出值传递给变量

时间:2018-03-20 08:25:01

标签: sql sql-server tsql

这是一个列数为变量的示例。我这样做,但在@VigenciaHastaValor我有一个空。

DECLARE @VigenciaHastaValor NVARCHAR(MAX);
DECLARE @VigenciaHasta NVARCHAR(MAX);
SET @VigenciaHasta = N'SELECT'+ @VigenciaHastaValor+' = [2]
       FROM
    (SELECT ROW_NUMBER() 
        OVER (ORDER BY SECMAX) AS Row 
     ,[2]
      ,[3]
      ,[4]
      ,[5]
    FROM [interurbano].[dbo].[sonpruebas]) AS EMP
WHERE Row = (SELECT COUNT(*)  FROM [interurbano].[dbo].[sonpruebas] ) PRINT(@VigenciaHastaValor)'



 EXEC sp_executesql @VigenciaHasta,N'@name NVARCHAR(50) OUTPUT',
        @VigenciaHastaValor OUTPUT
 PRINT(@VigenciaHastaValor)

1 个答案:

答案 0 :(得分:0)

是的,我找到了解决方案

...
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-execute');
grunt.registerTask("default", ["execute", "watch"]);
...