Solved

triggering text output from T-SQL MS 2008

Posted on 2013-12-02
4
296 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In this article I will describe the Backup & Restore 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 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 to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

759 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now