Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Two eyes are better than ONE

Author  Topic 

bvanyangu
Starting Member

20 Posts

Posted - 2014-06-17 : 07:45:33

Msg 156, Level 15, State 1, Line 21
Incorrect syntax near the keyword 'if'.
Msg 544, Level 16, State 1, Line 2
Cannot insert explicit value for identity column in table 'Property_Dim' when IDENTITY_INSERT is set to OFF.


For the Syntax, I tried to paste the same sentence from the other tables I created with no problem and I still get the same Error

Any advise on other ways to load Fact table besides this way??







-- Create Property dimension
if exists (select * from sys.tables where name = 'Property_Dim')
drop table Property_Dim
go

create table Property_Dim
([Property_Key] [int] IDENTITY(1,1) NOT NULL,
[Property_ID] [int] NOT NULL,
[Property Usage] [varchar](250) NULL,
[Property City] [varchar](250) NULL,
[Property State] [varchar](250) NULL,
[Property Zip] [varchar](250) NULL,
[RealEstateAgentName] [varchar](250) NULL,
[RealEstateAgentPhone] [varchar](250) NULL,
[RealEstateAgentEmail] [varchar](250) NULL,
[PropertyChecksum] [int] NULL,
[StartDate] [datetime] NULL,
[EndDate] [datetime] NULL,
[SSN] [varchar](250) NULL)

go

insert into Property_Dim(
[Property_Key] ,
[Property_ID],
[Property Usage] ,
[Property City] ,
[Property State] ,
[Property Zip] ,
[RealEstateAgentName] ,
[RealEstateAgentPhone] ,
[RealEstateAgentEmail] ,
[PropertyChecksum] ,
[StartDate] ,
[EndDate],
[SSN])



webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2014-06-17 : 07:51:21
No matter how many eyes... I don't know what you want and I don't see where your post can help us to help you!

Sorry


Too old to Rock'n'Roll too young to die.
Go to Top of Page

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2014-06-17 : 07:53:14
you need to SET INDENTITY_INSERT ON if explicitly enetring values into identity column.
BTW the insert script looks incomplete.

Javeed Ahmed
Go to Top of Page
   

- Advertisement -