[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Storing variable itnto declared variable in stored procedure

Posted on 2008-06-26
3
Medium Priority
?
1,655 Views
Last Modified: 2010-04-21
Hi,

I wat to create stored procedure in sql server 2005.
1) i want to retirve data from table1 and assign to variable which would have declared in stored procdeure. Later i will be using this variable in stored procedure.
i..,
Create   PROCEDURE [dbo].[sp1]  
BEGIN  
  Declare @NewEventCode   varchar(20)
//i want to retreive data rom table1( which will have only one record and one column ) and assign the value to @NewEventCode  .
like ..
"select  code1  to @NewEventCode   from table1 "



Can you please help us on this.
thanks,
Ram


0
Comment
Question by:ram27
[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
3 Comments
 
LVL 60

Accepted Solution

by:
chapmandew earned 500 total points
ID: 21878048
declare @neweventcode int

select @neweventcode = code1 from table1
0
 

Author Closing Comment

by:ram27
ID: 31471132
Thanks a lot
0
 
LVL 18

Expert Comment

by:Richard Lee
ID: 21878310
To achieve what you want you need to use the following SQL Query

Declare @NewEventCode   varchar(20)

Select @NewEventCode = table1.EventCode
  From table1
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

650 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