dbTalk Databases Forums  

output parameters from row with max id

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss output parameters from row with max id in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
mcolson
 
Posts: n/a

Default output parameters from row with max id - 07-31-2007 , 04:45 PM






I am trying to select multiple values from the row with the max id,
and output them within my stored procedure. How would I combine the
following two rows so that I only need to use "from mytable where
IDnum = (select (max(IDnum)) from mytable))" once. I have at least 8
other outputs I will be setting and would like this to work more
efficiently than setting each individually... if possible.

set @outmtd = (select outmtd from mytable where IDnum = (select
(max(IDnum)) from mytable))
set @outytd = (select outytd from mytable where IDnum = (select
(max(IDnum)) from mytable))

Thanks for any help you can give

Matt


Reply With Quote
  #2  
Old   
--CELKO--
 
Posts: n/a

Default Re: output parameters from row with max id - 07-31-2007 , 05:02 PM






Quote:
I am trying to select multiple values from the row with the max id, and output them within my stored procedure.
Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, data types, etc. in
your schema are. If you know how, follow ISO-11179 data element naming
conventions. Sample data is also a good idea, along with clear
specifications. It is very hard to debug code when you do not let us
see it.



Reply With Quote
  #3  
Old   
shiju
 
Posts: n/a

Default Re: output parameters from row with max id - 07-31-2007 , 10:29 PM



On Aug 1, 2:45 am, mcolson <mcolson1... (AT) gmail (DOT) com> wrote:
Quote:
I am trying to select multiple values from the row with the max id,
and output them within my stored procedure. How would I combine the
following two rows so that I only need to use "from mytable where
IDnum = (select (max(IDnum)) from mytable))" once. I have at least 8
other outputs I will be setting and would like this to work more
efficiently than setting each individually... if possible.

set @outmtd = (select outmtd from mytable where IDnum = (select
(max(IDnum)) from mytable))
set @outytd = (select outytd from mytable where IDnum = (select
(max(IDnum)) from mytable))

Thanks for any help you can give

Matt
I think this is what looking

select @outytd=outytd,@outmtd=outmtd
from mytable where IDnum = (select
(max(IDnum)) from mytable)



Reply With Quote
  #4  
Old   
mcolson
 
Posts: n/a

Default Re: output parameters from row with max id - 08-01-2007 , 08:04 AM



On Jul 31, 10:29 pm, shiju <shiju.sam... (AT) gmail (DOT) com> wrote:
Quote:
On Aug 1, 2:45 am, mcolson <mcolson1... (AT) gmail (DOT) com> wrote:> I am trying to select multiple values from the row with the max id,
and output them within my stored procedure. How would I combine the
following two rows so that I only need to use "from mytable where
IDnum = (select (max(IDnum)) from mytable))" once. I have at least 8
other outputs I will be setting and would like this to work more
efficiently than setting each individually... if possible.

set @outmtd = (select outmtd from mytable where IDnum = (select
(max(IDnum)) from mytable))
set @outytd = (select outytd from mytable where IDnum = (select
(max(IDnum)) from mytable))

Thanks for any help you can give

Matt

I think this is what looking

select @outytd=outytd,@outmtd=outmtd
from mytable where IDnum = (select
(max(IDnum)) from mytable)
that was exactly what I needed. Thanks



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.