msg 4902 sql

  • I am building a database in SQL2008 R2. When I run my script.

    CREATE TABLE [disaster_management_DEV].[dbo].[TWITTER_T] (

    [TWITTER_ID] INTEGER IDENTITY(1,1) NOT NULL,

    [COMMUNICATION_ID] INTEGER NOT NULL,

    [TWITTER].[SUBJECT] VARCHAR(20) NOT NULL,

    [TWITTER_MESSAGE] TEXT NOT NULL,

    CONSTRAINT [PK_TWITTER_T] PRIMARY KEY ([TWITTER_ID])

    )

    GO

    ALTER TABLE [disaster_management_DEV].[dbo].[TWITTER_T] ADD CONSTRAINT [COMMUNICATION_T_TWITTER_T]

    FOREIGN KEY ([COMMUNICATION_ID]) REFERENCES [disaster_management_DEV].[dbo].[COMMUNICATION_T] ([COMMUNICATION_ID])

    GO

    I have revived the error message below.

    Msg 102, Level 15, State 1, Line 6

    Incorrect syntax near '.'.

    Msg 4902, Level 16, State 1, Line 3

    Cannot find the object "disaster_management_DEV.dbo.TWITTER_T" because it does not exist or you do not have permissions.

    Msg 1767, Level 16, State 0, Line 3

    Foreign key 'TWITTER_T_ATTACHMENT_AT' references invalid table 'disaster_management_DEV.dbo.TWITTER_T'.

    Msg 1750, Level 16, State 0, Line 3

    Could not create constraint. See previous errors.

  • The problem is this column

    [TWITTER].[SUBJECT] VARCHAR(20) NOT NULL,

    Should that be

    [TWITTER_SUBJECT] VARCHAR(20) NOT NULL,

  • 😀 Thank you very much. I have been overlooking that typo for 3 days. :w00t:

  • Msg 4902, Level 16, State 1, Line 3

    Cannot find the object "disaster_management_DEV.dbo.TWITTER_T" because it does not exist or you do not have permissions.

    Fix the statement to read like this:

    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [dbo].[FK_Product_SMC]

  • johnwalker10 (11/2/2015)


    Msg 4902, Level 16, State 1, Line 3

    Cannot find the object "disaster_management_DEV.dbo.TWITTER_T" because it does not exist or you do not have permissions.

    Fix the statement to read like this:

    ALTER TABLE [dbo].[Products] DROP CONSTRAINT [dbo].[FK_Product_SMC]

    The issue isn't with the constraint, the constraint is syntax correct, the problem is with the create table syntax, a column name can't have a 2 part identifier the ].[ should be changed to whatever the space seperator for the end user is, be it a space, underscore, or use CamelCase.

    As the table couldn't be created the constraint also couldn't be created.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply