It does not create or modify the table.
It gives an error on the AUTO_INCREMENT part of the statement.
It should create or update the table.
It should not give an error.
Instead of using AUTO_INCREMENT, SQL server requires IDENTITY(1,1).
The first number between brackets is the starting value, the second is the increment.
Example:
CREATE TABLE Persons (
ID int IDENTITY(1,1) PRIMARY KEY,
Name varchar(255) NOT NULL
);
Is this a big change? Would it be easy for a first PR?
I got the same problem.
Is there a solution to this problem?
Oh God! It's 2020 and this is still open. Please guyz, fix this ASAP.
FYI: I am using HeidiSql v10.3
Also running into this today. One of the only reasons I have to open SSMS :(
Here is a script to generate a table on MS SQL 12.0.5223.6 that illustrates the problem:
CREATE TABLE [dbo].[User](
[Username] [nvarchar](20) NOT NULL,
[FullName] [nvarchar](50) NOT NULL,
[EmailAddress] [nvarchar](100) NULL,
[LastLoginDate] [datetime] NULL,
[IsAdministrator] [bit] NULL,
[Roles] [int] NOT NULL,
[Id] [int] IDENTITY(1,1) NOT NULL,
[CreatedAt] [datetime2](7) NOT NULL,
[CreatedBy] [nvarchar](20) NOT NULL,
[ModifiedAt] [datetime2](7) NULL,
[ModifiedBy] [nvarchar](20) NULL,
[LastPortfolioId] [int] NULL,
CONSTRAINT [PK__User__536C85E5B3CDBFE3] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[User] ADD DEFAULT (getdate()) FOR [CreatedAt]
GO
ALTER TABLE [dbo].[User] ADD DEFAULT (suser_sname()) FOR [CreatedBy]
GO
HeidiSQL 10.3.0.5838 does not detect the primary key:
Here is a script that selects primary key indices on MS SQL (probably not very early versions of MS SQL):
select schema_name(tab.schema_id) as [schema_name],
tab.[name] as table_name,
pk.[name] as pk_name,
col.name as col_name
from
sys.tables tab
left outer join sys.indexes pk on tab.object_id = pk.object_id and pk.is_primary_key = 1
left join sys.index_columns ic on ic.index_id = pk.index_id and ic.object_id = tab.object_id
inner join sys.columns col on ic.object_id = col.object_id and ic.column_id = col.column_id
order by schema_name(tab.schema_id),
tab.[name]