Solved

My SQL Variable in Stored Procedure

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Creating and Managing Databases with phpMyAdmin in cPanel.
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

690 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