Insert data into sql database

Hi,

I need to insert each row of datatable into SQL table, however i could add whole table at once but i need to insert each row from that particular datatable in for each row. so how can i give expression for that? Insert activity is asking for Datatable as input.

Regards,
Soorya prasad

@soorya_prasad You need to use Execute Non Query Activity, Pass the Query to Insert into the Table

@soorya_prasad

Sorry i am not wrong, you want to validate the data and if that row is passed then you need to insert to SQL table.

If that is the case, you can put a condition in For each Row activity, put a if condition that if your condition satisfies, place a Execute Non query activity else place continue activity

Hope this helps

Thanks

@supermanPunch
Can you please give me the exact query as i am new to SQL queries.

@soorya_prasad It will be something like this:
INSERT INTO TableName(Column1,Column2,Column3,Column4) VALUES (“A”,“B”,“C”,“D”)

You can use variables as values also instead of A, B, C and D String values

@soorya_prasad

"INSERT INTO [Table] (Column1) VALUES (Variable1,Variable2)"

We have nearly 100 columns. so I am looking for a different way and i found it.
Thanks for your opinions

1 Like

@soorya_prasad Please Share the Solution you have found, So It might be useful for others in Forum who would want to do the same :sweat_smile:

1 Like

@supermanPunch Hi,
Actually i used merge data table if it already has some data, for the first run i just directly write in a data table and inserted the merged data table. so that it will write all the rows into the data table and it will be inserted into the SQL table.

1 Like

Do you substitute column1 with the name of the column?