34,587
社区成员
发帖
与我相关
我的任务
分享
with
cr as
(Select A, B, C, D, E as OtherName, F, G from tb)
--以后调用的时候直接用cr就可以了,不用重复写了
select * from cr
select * from tb
declare @sql varchar(1000)
select @sql=ISNULL(@sql+',','')+name from syscolumns where id=OBJECT_ID('表名')
print @sql
customers 中的列 contact title 重命名为 title
select stuff((select ',['+[name]+']' from sys.all_columns where object_id=object_id('bom') for xml path('')),1,1,'')
先出来改吧一个吧。
有时就是*号都要写成所有字段名。