Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Store Procedure Help Expand / Collapse
Author
Message
Posted Thursday, March 21, 2013 7:17 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Friday, December 19, 2014 11:20 AM
Points: 243, Visits: 992
Hi Guys,

I need big favor.
I create new table Table_Track (ID, StoreProcedureName, CreatedDate, CreatedUserId). I want to know it is possible, if any store procedure runs though Application then Insert SP Name and UserId in Table_Track that i just created.

and One more question:- I want to add One new Variable in more than 100 SPs is there any way i can use any query to add all in once instead of one by one.
Please let me know if my question is not clear....

Any advise would be great appreciate.
Post #1434107
Posted Thursday, March 21, 2013 9:55 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Friday, December 19, 2014 11:20 AM
Points: 243, Visits: 992
Hi Guys,

I am thinking how i can solve my problem. I am thinking if someone can help me with my this question.

Let say here is my SP

Create Procedure Test
@Variable1 int
as
Select * from mytable
where @Variable1 = Variable1

--Here is my question
Declare @VariableName int

Set @VariableName = (Is there way when this SP runs i can get the name of the SP with Variable?)

PRINT @VariableName

Please guide me. Thank You.
Post #1434125
Posted Friday, March 22, 2013 7:59 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 2:58 PM
Points: 13,328, Visits: 12,826
Are you asking if there is a way to determine the name of the currently running stored proc from within the stored proc? I don't know of any way to do that in sql. I understand you have a lot of procs to add this to but I don't think you have much choice.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1434283
Posted Friday, March 22, 2013 8:36 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 7:52 AM
Points: 955, Visits: 2,634
You can do it using



CREATE PROCEDURE dbo.TEST

AS

DECLARE @ProcName sysname
SET @ProcName= OBJECT_NAME(@@PROCID)

Print @ProcName

GO


This will print the name "TEST".


_________________________________________________________________________
SSC Guide to Posting and Best Practices
Post #1434304
Posted Friday, March 22, 2013 8:54 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 2:58 PM
Points: 13,328, Visits: 12,826
Jason-299789 (3/22/2013)
You can do it using



CREATE PROCEDURE dbo.TEST

AS

DECLARE @ProcName sysname
SET @ProcName= OBJECT_NAME(@@PROCID)

Print @ProcName

GO


This will print the name "TEST".


+1 Gotta love learning new things every day!. Thanks.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1434312
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse