Create Table Problem

BigBaz's profile image BigBaz posted 4 years ago in Running SQL scripts Permalink

Hi

I have a table in a Test Server which I wanted to create in a Live Server. With Heidi I looked at the 'Create code' which gave me this:

CREATE TABLE "tblTimer" ( "ID" INT NOT NULL, "User1" NVARCHAR(15) NULL DEFAULT NULL COLLATE 'Latin1_General_CI_AS', "Count1" INT NULL DEFAULT '(0)', "Count2" INT NULL DEFAULT '(0)', "Timer" DATETIME NULL DEFAULT NULL, "Date1" DATETIME NULL DEFAULT NULL, "Date2" DATETIME NULL DEFAULT NULL ) ;

However, this is not what I require in that the 'ID' field has an Identity specification. I went to MS Management Studio and did a 'Script table to ...' and this is what I got:

USE [PGCPGC] GO

/** Object: Table [dbo].[tblTimer] Script Date: 22/05/2020 09:33:35 **/ SET ANSI_NULLS ON GO

SET QUOTED_IDENTIFIER ON GO

CREATE TABLE [dbo].[tblTimer]( [ID] [int] IDENTITY(1,1) NOT NULL, [User1] nvarchar NULL, [Count1] [int] NULL CONSTRAINT [DF_tblTimer_Count1] DEFAULT ((0)), [Count2] [int] NULL CONSTRAINT [DF_tblTimer_Count2] DEFAULT ((0)), [Timer] [datetime] NULL, [Date1] [datetime] NULL, [Date2] [datetime] NULL ) ON [PRIMARY]

GO

As you can see the 'ID' field here has the Identity specification set.

Does Heidi need a fix for this?

ansgar's profile image ansgar posted 4 years ago Permalink

Yes, there are some issues with the table designer in MS SQL mode. In such cases I recommend to make changes manually, per SQL command, not per table designer.

BigBaz's profile image BigBaz posted 4 years ago Permalink

Noted.

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