动态列名称

时间:2014-06-10 22:04:50

标签: sql-server-2008

DECLARE @count INT
DECLARE @intFlag INT
DECLARE @PropertyName Varchar(20)
SET @intFlag = 1 
SELECT @count = COUNT(*) FROM PropertyList
WHILE (@intFlag <= @count)
BEGIN 
SELECT @PropertyName =PropertyName FROM PropertyList WHERE PropertyNumber = @intFlag
SET @intFlag = @intFlag + 1
SELECT C.AGO_Exc, + 'C.' + @PropertyName    FROM [Crude Data] C
END
GO!

enter image description here

结果集在附图中。我真正想要的是'C' + @PropertyName应该充当列名。我怎么能这样做。

0 个答案:

没有答案