Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.

MSSQL: renaming a table fails

igitur's profile image igitur posted 5 years ago in General Permalink
Hi, when renaming a table, invalid SQL is executed.

Example: renaming dbo.HedgingBond to dbo.HedgingInstrument:

EXEC sp_rename "dbo"."HedgingBond", "HedgingInstrument";


The correct syntax is:
EXEC sp_rename "dbo.HedgingBond", "HedgingInstrument";
igitur's profile image igitur posted 5 years ago Permalink
Good description on http://blog.sqlauthority.com/2008/08/26/sql-server-how-to-rename-a-column-name-or-table-name/
igitur's profile image igitur posted 5 years ago Permalink
Also, renaming an existing column in a table in MS SQL should be as such:

EXEC sp_rename "CalculationHedgingInstruments.HedgingBondCode", "HedgingInstrumentCode", 'COLUMN';
Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.
Code modification/commit from ansgarbecker, 5 years ago, revision 4954
MSSQL: Prefer "schema.table" quoting over "schema"."table". See http://www.heidisql.com/forum.php?t=18476
ansgar's profile image ansgar posted 5 years ago Permalink
Done in r4954.
igitur's profile image igitur posted 3 years ago Permalink

This is a good example of an issue that can be marked as fixed. Refer to issue 21940 .

Please login to leave a reply, or register at first.