Click here to Skip to main content
15,891,473 members
Home / Discussions / Database
   

Database

 
AnswerRe: Conditional clause form two tables in sql server Pin
Varsha Ramnani18-Jan-12 21:56
professionalVarsha Ramnani18-Jan-12 21:56 
AnswerRe: Conditional clause form two tables in sql server Pin
David Skelly18-Jan-12 22:35
David Skelly18-Jan-12 22:35 
AnswerRe: Conditional clause form two tables in sql server Pin
sri08018819-Jan-12 0:06
sri08018819-Jan-12 0:06 
AnswerRe: Conditional clause form two tables in sql server Pin
SilimSayo23-Jan-12 9:45
SilimSayo23-Jan-12 9:45 
QuestionError message; with not much out on Google on this error Pin
vanikanc18-Jan-12 9:29
vanikanc18-Jan-12 9:29 
AnswerRe: Error message; with not much out on Google on this error Pin
SilimSayo18-Jan-12 9:38
SilimSayo18-Jan-12 9:38 
AnswerRe: Error message; with not much out on Google on this error Pin
Eddy Vluggen18-Jan-12 10:19
professionalEddy Vluggen18-Jan-12 10:19 
QuestionParameter names of Stored Procedures Pin
Dewald16-Jan-12 21:20
Dewald16-Jan-12 21:20 
Hi all,

I've often wondered about this and always simply worked my way around the issue but I would be curious to know what the correct approach is.

Say I have a stored proc like so:
SQL
CREATE PROCEDURE myStoredProc
    @myFirstParam INT = 0,
    @mySecondParam INT = 0
AS
BEGIN
    -- Do something
END


Now I want to call this proc, let's say from another proc where there is a local variable with the name @myLocalVar. I want to pass the value of that local variable to the second parameter of the stored proc so I call it as follows:

SQL
EXEC myStoredProc @mySecondParam = @myLocalVar


So far so good, but what if the name of that local variable was @mySecondParam (the same as the parameter name of the proc)? The following won't work:

SQL
EXEC myStoredProc @mySecondParam = @mySecondParam


So do I really have to create a new local variable with a different name so that I can pass it to the proc?
SQL
DECLARE @myNewVariable INT;
SET @myNewVariable = @mySecondParam;
EXEC myStoredProc @mySecondParam = @myNewVariable


Or is there a way I can pass a variable to a proc if the variable has the same name as the parameter name of the proc?

PS. I'm deliberately using an example where the first parameter of the proc is ommitted because I'm specifically interested in the scenario where the parameter names of a stored proc has to be specified (i.e. not inferred by their order).
AnswerRe: Parameter names of Stored Procedures Pin
Mycroft Holmes16-Jan-12 21:49
professionalMycroft Holmes16-Jan-12 21:49 
GeneralRe: Parameter names of Stored Procedures Pin
Dewald16-Jan-12 23:59
Dewald16-Jan-12 23:59 
GeneralRe: Parameter names of Stored Procedures Pin
sri08018819-Jan-12 0:09
sri08018819-Jan-12 0:09 
AnswerRe: Parameter names of Stored Procedures Pin
jschell18-Jan-12 8:43
jschell18-Jan-12 8:43 
QuestionHow to insert same record multiple times in Mysql using single query and not using for loop. Pin
sr15915-Jan-12 23:03
sr15915-Jan-12 23:03 
AnswerRe: How to insert same record multiple times in Mysql without using for loop. Pin
phil.o15-Jan-12 23:36
professionalphil.o15-Jan-12 23:36 
GeneralRe: How to insert same record multiple times in Mysql without using for loop. Pin
sr15916-Jan-12 0:41
sr15916-Jan-12 0:41 
AnswerRe: How to insert same record multiple times in Mysql without using for loop. Pin
Simon_Whale16-Jan-12 0:22
Simon_Whale16-Jan-12 0:22 
AnswerRe: How to insert same record multiple times in Mysql using single query and not using for loop. Pin
Jörgen Andersson16-Jan-12 0:57
professionalJörgen Andersson16-Jan-12 0:57 
AnswerRe: How to insert same record multiple times in Mysql using single query and not using for loop. Pin
Simon_Whale16-Jan-12 1:04
Simon_Whale16-Jan-12 1:04 
GeneralRe: How to insert same record multiple times in Mysql using single query and not using for loop. Pin
sr15916-Jan-12 1:22
sr15916-Jan-12 1:22 
GeneralRe: How to insert same record multiple times in Mysql using single query and not using for loop. Pin
Simon_Whale16-Jan-12 1:26
Simon_Whale16-Jan-12 1:26 
AnswerRe: How to insert same record multiple times in Mysql using single query and not using for loop. Pin
David Skelly16-Jan-12 2:23
David Skelly16-Jan-12 2:23 
AnswerRe: How to insert same record multiple times in Mysql using single query and not using for loop. Pin
SilimSayo16-Jan-12 7:06
SilimSayo16-Jan-12 7:06 
QuestionVS2010 Database Project Problem Pin
Kevin Marois14-Jan-12 7:11
professionalKevin Marois14-Jan-12 7:11 
QuestionProblem with Multiple search Stored Procedure Pin
reogeo200812-Jan-12 22:19
reogeo200812-Jan-12 22:19 
AnswerRe: Problem with Multiple search Stored Procedure Pin
Mycroft Holmes12-Jan-12 23:44
professionalMycroft Holmes12-Jan-12 23:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.