LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (February 2003, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
mathematical statistician
=========================================================================
Date:         Fri, 21 Feb 2003 13:47:45 -0500
Reply-To:     Katie Weaver <kweaver@U.WASHINGTON.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Katie Weaver <kweaver@U.WASHINGTON.EDU>
Subject:      Identity Field problem in SQL Server

I'm having a problem inserting rows from a SAS dataset into a SQL Server table. The SQL Server table contains an identity field which I want to be automatically updated by SQL Server when the SAS records are inserted. Here's the code I'm using:

libname b odbc dsn=SQLDB; proc sql; insert into b.SQLTABLE (Var1, Var2, Var3) select * from a.SASData; quit;

When I run the above code, I get the following error message:

ERROR: CLI execute error: [Microsoft][ODBC SQL Server Driver][SQL Server] Cannot insert explicit value for identity column in table 'SQLTABLE' when IDENTITY_INSERT is set to OFF. ERROR: ROLLBACK issued due to errors for data set B.SQLTABLE.DATA

I searched SAS Technical Support and found that SN-002627 addresses this problem. It suggests three workaround solutions, one of which is: 'Use proc sql pass-through with execute insert statements. Here the identity variable is automatically updated by SQL Server.'

Can someone explain to me what 'execute insert statements' are and how I can modify the code above to use execute insert statements?


Back to: Top of message | Previous page | Main SAS-L page