Hi,
I have a table "Del_Table", which must contain a column with autoincrement ability. I have added one column named as "Auto" and put it as Primary key, Identity and Integer. I am grabbing the data from an XML file. I have tried with the following Stored Procedure, but it gives an error as "An explicit value for the identity column in Del_Table can only be specified when a column list is used and IDENTITY_INSERT is ON". I have tried to to turn on IDENTITY_INSERT but still it does not work.
Code Snippet
CREATE PROCEDURE insertForecast
(@.OrderDoc ntext)
AS
DECLARE
@.hDoc int
EXEC sp_xml_preparedocument
@.hDoc output,
@.OrderDoc
INSERT INTO [Del_Table]
SELECT *
from OPENXML (@.hDoc,'Data/Delivery_Forecast/Forecast',3)
with
(
[ID] numeric '@.mp:id',
Document_Number char(35) '@.Document_Number',
Com_Date char(35) '@.Com_Date',
Code char (35) '@.code',
Port char (35) '@.port',
EPort char (35) '@.eport',
Number char (35) '@.number',
Instruction_Code char (35) '@.inst_Code',
Delivery_Date char (35) '@.del_date',
Quantity char (35) '@.quantity',
Status_Indicator char (35) '@.status_indicator'
)
ORDER BY
Document_Number
EXEC sp_xml_removedocument @.hDoc
GO
Any suggestions?
Thanks...
Specify the columns in the INSERT statement like the error message is stating (and still use the IDENTITY_INSERT of course).
WesleyB
Visit my SQL Server weblog @. http://dis4ea.blogspot.com
No comments:
Post a Comment