英文:
How to rename a table that has ".csv" in the name
问题
我有一些表的名称以.csv
结尾。即schema.table1.csv,schema.table2.csv。
如何去除.csv
或重命名它们而不包含有问题的字符?
根据这个Stack Overflow问题,我尝试了这个:
exec sp_rename @objname = 'schema.[table1.csv]', @newname = 'table1';
但当我运行它时,我收到了以下错误消息:
为存储过程或函数sp_rename提供的参数不足。
根据@AlwaysLearning的问题,这是SELECT @@VERSION
的结果:
Microsoft Azure SQL Data Warehouse - 10.0.20438.0 Jan 10 2023 20:57:20 Copyright (c) Microsoft Corporation
英文:
I have several tables whose names end with .csv
. I.e. schema.table1.csv, schema.table2.csv.
How can I remove the .csv
or rename them without the offending characters?
Per this SO question I tried this:
exec sp_rename @objname = 'schema.[table1.csv]', @newname = 'table1';
But I'm getting this error when I run it:
> An insufficient number of arguments were supplied for the procedure or function sp_rename.
Per @AlwaysLearning's question, here's the result of SELECT @@VERSION
:
>Microsoft Azure SQL Data Warehouse - 10.0.20438.0 Jan 10 2023 20:57:20 Copyright (c) Microsoft Corporation
答案1
得分: 2
你可以使用以下命令:
RENAME OBJECT schema.[table1.csv] TO [table1];
详细信息请参考:https://learn.microsoft.com/en-us/sql/t-sql/statements/rename-transact-sql?view=azure-sqldw-latest
(顺便说一句,在Azure Synapse中,sp_rename是完全不同的东西。截止到今天,它仅支持对列的重命名。详细信息请参考这里:https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-rename-transact-sql?view=azure-sqldw-latest)
英文:
you can use:
RENAME OBJECT schema.[table1.csv] TO [table1];
for details see: https://learn.microsoft.com/en-us/sql/t-sql/statements/rename-transact-sql?view=azure-sqldw-latest
(Btw: sp_rename is totally something different in Azure Synapse. As of today It only supports renaming of a column only. See details here: https://learn.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-rename-transact-sql?view=azure-sqldw-latest)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论