Wrox Home  
Search P2P Archive for: Go

  Return to Index  

sql_language thread: Re: select max into a @variable


Message #1 by David Cameron <dcameron@i...> on Thu, 2 Aug 2001 09:14:07 +1000
Or SET @var = (SELECT MAX(emp_id) FROM table)
If you are doing this after inserting a record it may be better to use
@@IDENTITY


regards
David Cameron
nOw.b2b
dcameron@i...

-----Original Message-----
From: Jaya John [mailto:jaya_john@h...]
Sent: Friday, 27 July 2001 11:50 PM
To: sql language
Subject: [sql_language] Re: select max into a @variable


declare the variable as

v_count   number;
e.g:
select max(emp_id)
into v_count
from employee;
now the variable v_count holds the value of the max(emp_id) and can be used.
----- Original Message -----
From: "Fotopoulos, Lefteris" <LFot@e...>
To: "sql language" <sql_language@p...>
Sent: Friday, July 27, 2001 7:28 AM
Subject: [sql_language] select max into a @variable


> How can i select max(column) into a stored_proc variable?
>
> e.g. set @var = select max(column) from table.
>
> So i want @var to hold the number that 'select max(column) from table'
> returns


  Return to Index