Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1656
  • Last Modified:

Storing variable itnto declared variable in stored procedure

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
ram27
Asked:
ram27
1 Solution
 
chapmandewCommented:
declare @neweventcode int

select @neweventcode = code1 from table1
0
 
ram27Author Commented:
Thanks a lot
0
 
Richard LeeSoftware EnthusiastCommented:
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now