Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERT INTO SELECT Problem

Status
Not open for further replies.

TomBarrand

Programmer
Joined
Aug 9, 2000
Messages
162
Location
GB
I have got the following SQL statement:

INSERT INTO FOB

SELECT *
FROM FOB, Purch_Ord_Line
WHERE FOB.Purch_Ord_Line_No = Purch_Ord_Line.Purch_Ord_Line_No AND Purch_Ord_Line.Purch_Ord_No = 1885 AND Purch_Ord_Line.Revision_No = 0

but I get the error message below when I execute it:

Server: Msg 8101, Level 16, State 1, Line 1
An explicit value for the identity column in table 'FOB' can only be specified when a column list is used and IDENTITY_INSERT is ON.

Any ideas?
 
From the query , some records are taken from Fob and are inserted into the same.
The table fob has an identity column which means that the column will be incremented automatically every time a record is inserted. this done by server itself.
if we are supplying values for any identity column
we need to set Identity on . then proceed with the insert.
or
you can try any one of these
1 a.disable the identity
b. run the above sql
c.enable the identity

2.try
insert into fob
(col1,col2,col3)

select
co1,col2,col3
from
fob

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top