2

There is no table named [dbo].[tblStoTConfig] , but when I run the below query it gives error. Cannot create table, object name already exists. Cannot create constraint.

create table [dbo].[tblStoTConfig]
            (
                pkStoTconfig int IDENTITY(1,1) NOT NULL, 
                fkAccountID int NULL, 
                fkSpeechToTextProvider int NULL,   
                APIEndPointURL Varchar(250),
                AuthenticationKey Varchar(100),
                NotificationURL Varchar(250),
                ConfigVariableName1 varchar(100), 
                ConfigVariable1 varchar(250), 
                ConfigVariableName2 varchar(100), 
                ConfigVariable2 varchar(250), 
                ConfigVariableName3 varchar(100), 
                ConfigVariable3 varchar(250), 
                ConfigVariableName4 varchar(100), 
                ConfigVariable4 varchar(250),           
                CONSTRAINT Fk_tblStoTConfig_tblAccounts FOREIGN KEY (fkAccountID)
                        REFERENCES [dbo].[tblAccounts] ([pkAccountID]),
                CONSTRAINT Fk_tblStoTConfig_tblSpeechToTextProvider FOREIGN KEY (fkSpeechToTextProvider)
                        REFERENCES [dbo].[tblSpeechToTextProvider] ([pkSpeechToTextProvider]),
                CONSTRAINT [tblStoTConfig] PRIMARY KEY CLUSTERED 
                (
                  pkStoTconfig ASC
                )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
                ) ON [PRIMARY]

If i run

drop table [dbo].[tblStoTConfig]

it says object name doesn't exists.

Please give me some solution as I am stuck on this from last 2 days.

Thanks in advance.

1
  • 1
    Make sure you are running both the queries in same database or try using 3 part identifier while creating or dropping the table. DatabaseName.SchemaName.TableName Commented Jun 14, 2017 at 4:27

1 Answer 1

5

If you notice that in your script the constraint name is same as the table name.

CONSTRAINT [tblStoTConfig] PRIMARY KEY CLUSTERED 
                (
                  pkStoTconfig ASC
                )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
                ) ON [PRIMARY]

Change that and you are all set :)

Hope the answer helps.

Sign up to request clarification or add additional context in comments.

1 Comment

I am glad I was helpful. :-) Thanks @Prdp

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.