Solved

My SQL Variable in Stored Procedure

Posted on 2013-12-18
2
324 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
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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Suggested Solutions

Creating and Managing Databases with phpMyAdmin in cPanel.
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…

856 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