Question

How to execute "Raw SQL" in a script task process ...

Hi community!

 

How can i execute a sql query like : 



INSERT INTO [DestinationTable] (fields)

SELECT field1 field2, field3 ..

FROM [SourceTable]

I can't use ESQ and .Net "SqlCommand" class ask a SqlConnection and not a UserConnection ...



Can you help me?

Best regards,

Davyd

 

Like 0

Like

1 comments

Hi community!



I finally found the solution!!! : using the Class CustomQuery like this:

var userConnection = Get<UserConnection>("UserConnection");

string sql =" ......."; 

CustomQuery myQuery = new CustomQuery(userConnection);

myQuery .SqlText = sql;

using (DBExecutor dbExecutor = userConnection.EnsureDBConnection())

{

    dbExecutor.CommandTimeout = 0;

    myQuery .Execute();

}

return true;

Show all comments