Solved

triggering text output from T-SQL MS 2008

Posted on 2013-12-02
4
299 Views
Last Modified: 2013-12-02
Hi,

   I am looking to see if I can output the read-in params to a text file or some sort of visible output from a T-SQL in MS 2008? I have a bunch of front end code that fires off one of the T-SQL stored procedures passing it some parameters. I dont know the front end procedures and can not hence locate the params they are passing into the T-SQL, hence, I am trying to get these values once received by the T-SQL stored procedure. How do I go about it?


thx
0
Comment
Question by:LuckyLucks
  • 2
4 Comments
 
LVL 65

Expert Comment

by:Jim Horn
ID: 39690607
Huh?

Can't speak for the front-end, but regarding the back-end SQL, if your T-SQL calls a stored procedure or multi-line function, it can be edited to insert into a logging table.

If the T-SQL calls a view or another type of function, then it's not possible.
0
 

Author Comment

by:LuckyLucks
ID: 39690638
Sorry maybe my question is too simple but not clear i am guessing...


So here is what the SP looks like currently, call it mySP:

create procedure dbo.mySP
     @myparam1 int,
    @myparam2 varchar(200)

AS

DECLARE @myvar int


dbo.myFunction(myparam1, myparam2)


Now, here w/o knowing how the front end fires off this mySP, how can I get the myparam1 and myparam2 values?
0
 
LVL 18

Assisted Solution

by:UnifiedIS
UnifiedIS earned 250 total points
ID: 39690652
Build a table to log it and dump the parameters each time it is run:

NewlyCreatedLogTable will need a field for each of your parameters.  I also added a date/time stamp field

MyParam1 int,
MyParam2 varchar(200),
EventDTM datetime


INSERT INTO NewlyCreatedLogTable (MyParam1, MyParam2, EventDTM)
SELECT @myparam1, @myparam2, GETDATE()
0
 
LVL 65

Accepted Solution

by:
Jim Horn earned 250 total points
ID: 39690666
>Now, here w/o knowing how the front end fires off this mySP, how can I get the myparam1 and myparam2 values?
Based on the SP above, it will not successfully execute without having two parameters passed to it, such as...

exec mySP 42, 'banana'

Open in new window


So if by 'to get' you mean how can you view SP calls after the fact, you can manually log them based on the above post.   You can also run SQL Server Profiler and view the calls over a period of time, which also allows you to see any parameters passed.
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how the fundamental information of how to create a table.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question