Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

triggering text output from T-SQL MS 2008

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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.
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Via a live example, show how to setup several different housekeeping processes for a 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.

721 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