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
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)