我需要使用变量来设置名称行但我有错误
CREATE
PROCEDURE dbo.procedure (@var int)
AS
SELECT row_name as @var
FROM table
...
感谢您的帮助
答案 0 :(得分:0)
试试这个Sample脚本,我在程序中使用了样例表,通过变量的输入值将是别名列名
CREATE PROCEDURE Usp_procedure (@var int)
AS
Begin
DECLARE @Sql nvarchar(max)
SET @Sql='
SELECT EmployementStatus AS '+ QUOTENAME(CAST(@var AS VARCHAr(10)))+'
from [dbo].[EmployeeInfo]'
--Print @Sql
EXEC (@Sql)
END
EXEC Usp_procedure @var=1
结果
1
-------
Intern
Jr. DBA
答案 1 :(得分:0)
您可以使用Dynamic SQL实现此目的。像这样的东西
var linePoints = new List<Vector2>(){new Vector2(20, 30), new Vector2(200, 300)}; // C#
VectorLine myLine = new VectorLine("Line", linePoints, 2.0f);
myLine.Draw();