March 21, 2013 at 7:17 pm
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.
March 21, 2013 at 9:55 pm
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.
March 22, 2013 at 7:59 am
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 Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
March 22, 2013 at 8:36 am
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
March 22, 2013 at 8:54 am
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 Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply