Solved

My SQL Variable in Stored Procedure

Posted on 2013-12-18
2
325 Views
Last Modified: 2014-05-19
I wan to create a procedure that will allow me to enter 2 variables

each variable will be an int.

I have a number of tables where I will be updating based on the above variables

example

update table 1
set ID = variable1 where ID = varibale2

Any Ideas
0
Comment
Question by:Brogrim
[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 Comments
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 500 total points
ID: 39727357
Per the documentation:
http://dev.mysql.com/doc/refman/5.0/en/create-procedure.html

Delimiter //
Create Procedure MyProc (Proc1 int, Proc2 int)
BEGIN
  Update Table1
    Set ID = Proc1 where ID = Proc2;
END //
Delimiter ;

Open in new window

0
 
LVL 15

Expert Comment

by:Ess Kay
ID: 39727466
USE [YOURDATABASE]
GO
/****** Object:  StoredProcedure [dbo].[YOURPROCEDURE]    ******/
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE proc [dbo].[YOURPROCEDURE]
@variable1 as integer,
@varibale2 as integer
 as

update table1
set ID = @variable1 where ID = @varibale2

Open in new window

0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Suggested Solutions

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

749 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