日期:2014-05-18 浏览次数:20469 次
declare @A nvarchar(200) ='大小' declare @sql nvarchar(2000) set @sql ='select *,(CONVERT(varchar(50),(size/128))+''MB'')' + @A +' from sysfiles' exec (@sql)
------解决方案--------------------
DECLARE @A INT SET @A=888 declare @sql varchar(1000) set @sql='SELECT NAME AS ['+ltrim(@A)+'] FROM TABLE' exec(@sql)
------解决方案--------------------
写动态SQL 是可以的
DECLARE @A INT SET @A=888 declare @s varchar(100) set @s = 'select NAME AS '+convert(varchar(8),@a) + 'FROM TABLE' exec (@s)
------解决方案--------------------
DECLARE @A INT,@s varchar(100) SET @A=888 set @s='SELECT NAME AS ['+ltrim(@A)+'] FROM Table' exec(@s)
------解决方案--------------------
动态吧