?
Solved

My SQL Variable in Stored Procedure

Posted on 2013-12-18
2
Medium Priority
?
327 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 2000 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
In this article, we’ll look at how to deploy ProxySQL.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

771 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