Solved

triggering text output from T-SQL MS 2008

Posted on 2013-12-02
4
307 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 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 66

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

623 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