Solved

My SQL Variable in Stored Procedure

Posted on 2013-12-18
2
316 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
Comment Utility
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
Comment Utility
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Introduction In this installment of my SQL tidbits, I will be looking at parsing Extensible Markup Language (XML) directly passed as string parameters to MySQL 5.1.5 or higher. These would be instances where LOAD_FILE (http://dev.mysql.com/doc/refm…
As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now