Skip to content

ALTER TABLE statement has incorrect syntax on TSQL (MS SQL Server) #1853

@budiony

Description

@budiony

Preconditions

  • HeidiSQL version: 12.5.0.6691 and below
  • Database type and version: MS SQL 12.0
  • OS: Windows 10

Describe the bug

The ALTER TABLE statement produced by the Heidi when editing column of a table from UI has incorrect syntax on TSQL (MS SQL Server). The query produced by Heidi is:
ALTER TABLE "dbo"."SomeTable" ALTER COLUMN "SomeColumn" "SomeColumn" VARCHAR(20) NULL DEFAULT NULL COLLATE 'Cyrillic_General_CI_AS';

There two problems here:

  1. It seems that the column name in the query is duplicated;
  2. The collation should be without single/double quotes.

The correct syntax for the ALTER statement is:
ALTER TABLE dbo.SomeTable ALTER COLUMN SomeColumn VARCHAR(20) COLLATE Cyrillic_General_CI_AS NULL;

To Reproduce

  1. Edit particular column definition of a table from UI, for example try to change the type from VARCHAR(10) to VARCHAR(20);
  2. Click on the Save button
  3. See error message: SQL Error (102): Incorrect syntax near...

Screenshots or Crash reports

2023-09-21_123700

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugDefective behaviour in HeidiSQLnettype-mssqlSQL Server specific issue

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions