SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Any way to see or view the results of an execute sql task ?


Any way to see or view the results of an execute sql task ?

Author
Message
blasto_max
blasto_max
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1097 Visits: 480
I want to see the results of my execute SQL query. Is there any simple way to do that ? I am looking for some kind of viewer or even file where the results can be written to.
Koen Verbeeck
Koen Verbeeck
SSC Guru
SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)

Group: General Forum Members
Points: 60247 Visits: 13297
You cannot see this in SSIS itself.
You'll need to go to the database and check if the query was executed.
You could also use SQL Server Profiler to verify if the query has been sent to the database correctly.
Or you could implement some auditing in the query itself.

The Execute SQL Task will only tell you if the query has been successfully executed or not and how long it took.


How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
My blog at SQLKover.

MCSE Business Intelligence - Microsoft Data Platform MVP
pnr8uk
pnr8uk
SSC-Addicted
SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)

Group: General Forum Members
Points: 415 Visits: 493
Write the results of your SQL query out to a variable, try single row first, if you have a full result set then it gets a little more tricky.

1 . Create a string variable eg: @resultsfromquery.

2. In you SQL Task container, choose ResultSet Single row

3. Choose Result Set from the menu on the side GENERAL, ParameterMapping, Result Set, Expressions.

4. Set the Result Name to 0 and the VariableName to your variable eg: User::resultsfromquery

5. Add a breakpoint to your SQLTask, you can use Break when the container receives the OnPostExecute

6. Start Debug (F5)

7. When debug starts you will have the extra option of adding a WATCH window.

8. When the watch window appears drag your variable onto the watch window.

When your package hits the breakpoint, you will then see your results appear in your variable.

If you are doing a full result set you will need to set up a for each loop container :-)

Hope this helps

Paul
Koen Verbeeck
Koen Verbeeck
SSC Guru
SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)

Group: General Forum Members
Points: 60247 Visits: 13297
pnr8uk (10/28/2013)
Write the results of your SQL query out to a variable, try single row first, if you have a full result set then it gets a little more tricky.

1 . Create a string variable eg: @resultsfromquery.

2. In you SQL Task container, choose ResultSet Single row

3. Choose Result Set from the menu on the side GENERAL, ParameterMapping, Result Set, Expressions.

4. Set the Result Name to 0 and the VariableName to your variable eg: User::resultsfromquery

5. Add a breakpoint to your SQLTask, you can use Break when the container receives the OnPostExecute

6. Start Debug (F5)

7. When debug starts you will have the extra option of adding a WATCH window.

8. When the watch window appears drag your variable onto the watch window.

When your package hits the breakpoint, you will then see your results appear in your variable.

If you are doing a full result set you will need to set up a for each loop container :-)

Hope this helps

Paul


That only works with SELECT statements of course, which are kind of pointless in an Execute SQL Task unless you assign the results to a variable :-)


How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
My blog at SQLKover.

MCSE Business Intelligence - Microsoft Data Platform MVP
pnr8uk
pnr8uk
SSC-Addicted
SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)

Group: General Forum Members
Points: 415 Visits: 493
Well yes :-) but the poster seemed to want that? :-S
Koen Verbeeck
Koen Verbeeck
SSC Guru
SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)

Group: General Forum Members
Points: 60247 Visits: 13297
pnr8uk (10/28/2013)
Well yes :-) but the poster seemed to want that? :-S


Not sure, he doesn't mention the type of query :-)
If it's an update statement, you see nothing in SSIS.


How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
My blog at SQLKover.

MCSE Business Intelligence - Microsoft Data Platform MVP
pnr8uk
pnr8uk
SSC-Addicted
SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)SSC-Addicted (415 reputation)

Group: General Forum Members
Points: 415 Visits: 493
Dude... what are you trying to do here? I'm just trying to help the guy out, there's no mention of an update in his post or I wouldn't have put down my solution. I'm not trying to say you were wrong or anything. Aren't these forums about trying to provide a solution, not undermine any poster or helper?

I want to see the results of my execute SQL query. Is there any simple way to do that ? I am looking for some kind of viewer or even file where the results can be written to.
Koen Verbeeck
Koen Verbeeck
SSC Guru
SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)SSC Guru (60K reputation)

Group: General Forum Members
Points: 60247 Visits: 13297
Dude, relax. I was just pointing out that there's not enough information in the original post to know what kind of query it is.
If it is an update/delete, the variable is useless, if it's a select, it's not.


How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?
My blog at SQLKover.

MCSE Business Intelligence - Microsoft Data Platform MVP
below86
below86
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1728 Visits: 2715
This is one of two reasons I don't use the execute SQL task. If I get called at 1 AM because the SQL failed I want to know where it failed and what error I got. I don't want to have to rerun the SQL in SSMS to find the error. And I may have to determine if I can rerun the earlier steps in the SQL, may need to restore or recreate certain files. Not things you want to have to think about at 1 AM.

The second reason is I have to update the SSIS package anytime I make a SQL change. I know this can be a good thing if you keep versions of each update. But luckily we haven't ran into any issues, yet.

We use an 'Execute process task' to call a 'bat' file that executes the SQL. I can set this to put the log from the SQL out to a file that I can then review.

So until someone can tell me how I can see this same type of 'log' information for an execution of a SQL job, I will not be using the execute SQL task.

-------------------------------------------------------------
we travel not to escape life but for life not to escape us
Luis Cazares
Luis Cazares
SSC-Forever
SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)

Group: General Forum Members
Points: 40584 Visits: 19814
below86 (10/30/2013)
So until someone can tell me how I can see this same type of 'log' information for an execution of a SQL job, I will not be using the execute SQL task.

If you just want to know where and why the task failed, you could use SQL Server error handling to get an even better error log. To avoid changes on the SSIS package, you could simply use Stored Procedures instead of the full query.
I'm not sure that your way is the way to go, but if it works for you, then I can't suggest you to stop using it, just wanted to give some ideas.;-)


Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search