Insert Query in Execute database Query

Hi,

I am trying to write a insert query inside excel loop within a DB application…i want to use variable taken from excel sheet to insert into sql insert query like below but not working. so how can i use variables in insert query? e.g here DashboardName & LastRefresh are variables from excel which i want to use in query.
“Insert into ExcelData Values(”+"‘DashBoardName’,"+"‘LastRefresh’)"

Hi @vishal.kumar39

You can use the “Assign” activity to assign a string value to the query. Mention the Variable Name as and when required along with the value to are giving.

Cheers!

Hi @SuryaSunderRaj,

Not getting…Can you tell in little brief?

Thanks,
Vishal

Hi,

  1. Create an argument say sqlstmt
  2. Now use assign activity and assign value to sqlstmt
    arg 1 an dcomes from argument defined excel loop
    sqlstmt = “Insert into ExcelData Values" + arg1 + remaining argument or statment
  3. In Execute DB query select sqlstmt

Regards,
Amit Anand

Hi @amit_anand15,

Throwing error.
I am using -
"Insert into ExcelData Values "+DashboardName+LastRefresh in assign activity

DashboardName and lastRefresh should be within single quotes as those are strings. Can you tell how to give single quotes around DashboardName & LastRefresh in assign activity

Regards,
Vishal

Hi,

Please check on net for concatenating strings and giving escape character. Let me know if still you are not able to figure it out

Regards,
Amit Anand