从数据更改列名 [英] Changing Column name from Data
问题描述
亲爱的所有人,
我有一个有关更改表的列名的查询.
表格列的名称类似F1,F2等.实际名称在表格的第一行.
发生这种情况是因为我将一个Excel文件导入了以第一行为标题的sql文件.
所以我想更改列名称,例如F1 = Exchange,F2 = Stock等.
是否可以在一个查询中更改所有列的名称?
谢谢与问候.
Dear All,
I have a query about changing the column names of a table.
The table column has a names like F1,F2 etc. The actual names are in the first row of the table.
This happens because i imported a excel file into sql which has first row as a header.
so i want to change the column names like F1=Exchange,F2=Stock etc.
Is this possible to change all the columns name in one query?
Thanks & Regards.
推荐答案
是,请使用:
Yes use :
EXEC sp_rename 'database.tablename', 'oldname', 'newname';
http://msdn.microsoft.com/en-us/library/aa238878%28v = SQL.80%29.aspx [ ^ ]
http://msdn.microsoft.com/en-us/library/aa238878%28v=SQL.80%29.aspx[^]
这篇关于从数据更改列名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!