zimmer9
asked on
Do you know how I can resolve the error "Incorrect syntax near the keyword 'primary'? I am altering a column in a SQL Server 2008 table.
Do you know how I can resolve the error "Incorrect syntax near the keyword 'primary'?
I am altering a column in a SQL Server 2008 table.
ALTER TABLE dbo.tbl_BU_StopVoidPay
ALTER COLUMN stopID int primary key IDENTITY(1,1) NOT NULL
I am altering a column in a SQL Server 2008 table.
ALTER TABLE dbo.tbl_BU_StopVoidPay
ALTER COLUMN stopID int primary key IDENTITY(1,1) NOT NULL
ASKER
ALTER TABLE dbo.tbl_BU_StopVoidPay
ALTER COLUMN stopID int IDENTITY(1,1) NOT NULL primary key
Now I get the following response:
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'IDENTITY'.
ALTER COLUMN stopID int IDENTITY(1,1) NOT NULL primary key
Now I get the following response:
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'IDENTITY'.
This was taken from an answer, so should have worked out fine.
Then try an alteration like this:
Are you really altering a column? What type is it now? An int without the incrementing identity property?
Bye, Olaf.
Then try an alteration like this:
ALTER TABLE dbo.tbl_BU_StopVoidPay
ALTER COLUMN stopID int NOT NULL IDENTITY(1,1) primary key
Are you really altering a column? What type is it now? An int without the incrementing identity property?
Bye, Olaf.
ASKER
Here is what my problem was originally. I have 2 tables.
One table titled dbo.tbl_CSL_ImportSV has all the fields contained in table dbo.tbl_BU_StopVoidPay except that table dbo.tbl_BU_StopVoidPay contains 1 additional column titled stopID defined as (int, not null).
When I execute the following statement, I get the error:
INSERT INTO dbo.tbl_BU_StopVoidPay (bank, branch, chkNum, accountNum, chkDt,
typeSV, amount, dtCreated, dtCompleted, createdBy, completedBy,
entity, userid, howRecieved, sStatus)
(SELECT I.bank, I.branch, I.checks, I.custBase, I.chkDt, I.typeSV, I.amount,
I.procDate, I.dtImported, I.importedBY, I.importedBY, I.entity, I.userid, I.howRecieved,
I.sStatus
FROM dbo.tbl_CSL_ImportSV AS I)
Msg 515, Level 16, State 2, Line 1
Cannot insert the value NULL into column 'stopID', table 'CSL.dbo.tbl_BU_StopVoidPa y'; column does not allow nulls. INSERT fails.
The statement has been terminated.
One table titled dbo.tbl_CSL_ImportSV has all the fields contained in table dbo.tbl_BU_StopVoidPay except that table dbo.tbl_BU_StopVoidPay contains 1 additional column titled stopID defined as (int, not null).
When I execute the following statement, I get the error:
INSERT INTO dbo.tbl_BU_StopVoidPay (bank, branch, chkNum, accountNum, chkDt,
typeSV, amount, dtCreated, dtCompleted, createdBy, completedBy,
entity, userid, howRecieved, sStatus)
(SELECT I.bank, I.branch, I.checks, I.custBase, I.chkDt, I.typeSV, I.amount,
I.procDate, I.dtImported, I.importedBY, I.importedBY, I.entity, I.userid, I.howRecieved,
I.sStatus
FROM dbo.tbl_CSL_ImportSV AS I)
Msg 515, Level 16, State 2, Line 1
Cannot insert the value NULL into column 'stopID', table 'CSL.dbo.tbl_BU_StopVoidPa
The statement has been terminated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
So
Open in new window