HeidiSQL icon indicating copy to clipboard operation
HeidiSQL copied to clipboard

SQL Server: incorrect ALTER COLUMN statement generated from Heidi

Open budiony opened this issue 3 years ago • 2 comments

Preconditions

  • HeidiSQL version: 12.1.0.6566
  • Database type and version: MS SQL Server 11.0
  • OS: Windows

Describe the bug

HeidiSQL is wonderful application for managing SQL databases, it is perfect by my opinion when dealing with MySQL, however it has incorrect SQL statement generation when dealing with MSSQL Server, the ALTER TABLE / ALTER COLUMN statement sets the column name twice (instead of only 1 time), which produces of course SQL "Incorrect syntax" error.

To Reproduce

Example:

  1. The statement generated for altering the table column from HeidiSQL is: ALTER TABLE "dbo"."SomeTable" ALTER COLUMN "SomeColumn" "SomeColumn" VARCHAR(50) NOT NULL COLLATE 'Cyrillic_General_CI_AS';
  2. It should be: ALTER TABLE "dbo"."SomeTable" ALTER COLUMN "SomeColumn" VARCHAR(50) COLLATE Cyrillic_General_CI_AS NOT NULL;
  3. Also, note that the collation part is also invalid (it must be set without single quotes), which again produces SQL "Incorrect syntax" error.
  4. The NOT NULL statement should be the last also.
  5. The above problems occur every time you create/modify MSSQL table (in fact you cannot modify MSSQL table via HeidiSQL interface, instead you have to copy the statements generated from the log file, correct them manually and run them in SQL editor), so I believe that fixing them will benefit greatly the community.

Screenshots or Crash reports

budiony avatar Nov 17 '22 13:11 budiony

Any update on this? Getting all sorts of errors when using HeidiSQL with a MSSQL database.. Do I need to change any settings?

fonziemedia avatar Jun 01 '23 14:06 fonziemedia

It's indeed a quirk in HeidiSQL's automatic query generation with MS SQL Server databases.

mahdi666 avatar Aug 17 '23 08:08 mahdi666