我正在将表插入SQL数据库,并且我的数据集中有ID
列。要插入它,我需要将identity_insert设置为on。如何在identity_insert
中使用SAS上设置proc sql
?
proc sql;
insert into db.app (id, name)
select a.id a.name from work.test as a;
quit;
每this SAS tech support note,您可以按以下步骤操作:
libname x odbc dsn=mssqlserver user=xxx password=yyy
dbconinit='set IDENTITY_INSERT foo ON'
dbconterm='set IDENTITY_INSERT foo OFF';
proc append base=x.foo data=work.foo;
run;
这假设您需要实际设置id
变量。如果您想自动将id
变量从插入语句中删除,则应该可以。