DATA Step, Macro, Functions and more

insert data into sql table

Reply
Contributor
Posts: 47

insert data into sql table

 

I am trying to insert a data in SQL server table using SAS 

 

Below is the code that I have written 

 

%macro lzlib;


LIBNAME LZZ OLEDB BULKLOAD=YES
DBCOMMIT=0
CURSOR_TYPE=STATIC
BL_KEEPIDENTITY=YES
BL_KEEPNULLS=NO
DIRECT_EXE=DELETE
PROPERTIES=('Integrated Security'=SSPI
'Persist Security Info'=TRUE
'Initial Catalog'=Customer_account)
PROMPT=NO
REREAD_EXPOSURE=NO
PROVIDER=SQLOLEDB
DATASOURCE="dwh-i-sql"
SCHEMA=DZS
ROWSET_SIZE=32767
UPDATE_MULT_ROWS=YES
PRESERVE_GUID=yes;


PROC SQL;
INSERT INTO LZZ.CUST_DIM
SELECT DATO
,JOBNAME
,RUNDATE
,EXECUTION_STATUS
,COMPARE
,LcOMPARE_RESULT
,OUTPUT_FLAT_FILE_EXISTS
,FOLDER_LINK
,FILE_NAME
,ADD_INFO
,FILE_EXISTS
,HOST_FILE_DOWNLOAD
,FILE_READ
,HOST_FILE_READ
,COMPARE_PROCEDURE
,COMPARE_STATUS
,BASEDATASETOBS
,COMPAREDATASETOBS
,BASEDATASETVAR
,COMPAREDATASETVAR FROM FINAL;
QUIT;


%mend;

 

This is the error that comes up 

 

ERROR: Execute error: IRowsetFastLoad::InsertRow failed. : Unspecified error

ERROR: ROLLBACK issued due to errors for data set LZZ.CUST_DIM.DATA.

 

 

Thanks!!

 

Super User
Posts: 5,826

Re: insert data into sql table

Try

options msglevel=i sastrace=',,,d' sastraceloc=saslog;

Might give you some more info in the log.

Check the data and try to see if they break any constraints, or if you have any read only columns.

Check in SQL Server logs, enable additional audit if necessary.

Data never sleeps
Contributor
Posts: 47

Re: insert data into sql table

All the constraints are fine .I am not able to undertsand what the error is
Super Contributor
Posts: 498

Re: insert data into sql table

Super User
Super User
Posts: 7,847

Re: insert data into sql table

[ Edited ]

Most likely you have a type conflict for one of the column or perhaps just one of the values for one of the columns.

 

Find an example observation that it cannot insert.

Then repeatally try loading the row with different combinations of variables selected to see which variable(s) are causing the problem.

 

You should probably check the date varaibles first. SAS stores DATE and DATETIME values differently, but many DBMS have only one data type for dates.  You might need to convert your SAS DATE value to a DATETIME value to put it into the target variable.

 

Ask a Question
Discussion stats
  • 4 replies
  • 471 views
  • 0 likes
  • 4 in conversation