Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

triggering text output from T-SQL MS 2008

Posted on 2013-12-02
4
Medium Priority
?
332 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 66

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 1000 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 66

Accepted Solution

by:
Jim Horn earned 1000 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

926 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