I think this should be easy, but maybe my brain is just not working today,
can anyone offer suggestions?
I have a table, Table1 (simplified):
ID dollars
1 15
2 30
4 22
Using T-SQL, how can I get the ID value for the record with the highest
number in the dollars column?
"Select MAX(dollars) from Table1" gives me the actual highest value, but I
need to know the record from where that value came from.
Any thoughts?select ID from Table1 where dollars=(Select MAX(dollars) from Table1)
Note that unless there is a unique constraint on the dollars column,
you may get multiple rows back.|||That's what I needed...thanks.
<markc600@.hotmail.com> wrote in message
news:1134845143.777978.193910@.g14g2000cwa.googlegroups.com...
> select ID from Table1 where dollars=(Select MAX(dollars) from Table1)
> Note that unless there is a unique constraint on the dollars column,
> you may get multiple rows back.
>
Showing posts with label corresponding. Show all posts
Showing posts with label corresponding. Show all posts
Tuesday, March 27, 2012
Monday, March 12, 2012
Getting parameter's user-defined datatype?
Hey,
Is there any way to get routine's parameter's user-defined datatype from
system tables/views?
I see there is a corresponding field in INFORMATION_SCHEMA.PARAMETERS view,
but it is said to be for future use...
Thank You in advance,
MartinThis should server as a starting point:
SELECT *
FROM syscolumns as sc
INNER JOIN systypes AS st on sc.xtype = st.xtype
where sc.id IN (SELECT id FROM sysobjects WHERE type = 'P')
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Martin H." <Martin H.@.discussions.microsoft.com> wrote in message
news:BA5DD35C-2FAD-473D-9524-0915FB29AF30@.microsoft.com...
> Hey,
> Is there any way to get routine's parameter's user-defined datatype from
> system tables/views?
> I see there is a corresponding field in INFORMATION_SCHEMA.PARAMETERS view
,
> but it is said to be for future use...
> Thank You in advance,
> Martin|||Martin H. wrote:
> Hey,
> Is there any way to get routine's parameter's user-defined datatype from
> system tables/views?
> I see there is a corresponding field in INFORMATION_SCHEMA.PARAMETERS view
,
> but it is said to be for future use...
--BEGIN PGP SIGNED MESSAGE--
Hash: SHA1
This works:
select parameter_name, data_type
from information_schema.parameters
where specific_name = 'procedure name'
Substitute your procedure name in the WHERE clause.
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
--BEGIN PGP SIGNATURE--
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/ AwUBQlJLyIechKqOuFEgEQKibgCcD46kIxMkKQya
73lwxg0DrXcPIOoAn0Zr
W/GAuqaueyUtevN4hQnU1T0D
=/yvi
--END PGP SIGNATURE--
Is there any way to get routine's parameter's user-defined datatype from
system tables/views?
I see there is a corresponding field in INFORMATION_SCHEMA.PARAMETERS view,
but it is said to be for future use...
Thank You in advance,
MartinThis should server as a starting point:
SELECT *
FROM syscolumns as sc
INNER JOIN systypes AS st on sc.xtype = st.xtype
where sc.id IN (SELECT id FROM sysobjects WHERE type = 'P')
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Martin H." <Martin H.@.discussions.microsoft.com> wrote in message
news:BA5DD35C-2FAD-473D-9524-0915FB29AF30@.microsoft.com...
> Hey,
> Is there any way to get routine's parameter's user-defined datatype from
> system tables/views?
> I see there is a corresponding field in INFORMATION_SCHEMA.PARAMETERS view
,
> but it is said to be for future use...
> Thank You in advance,
> Martin|||Martin H. wrote:
> Hey,
> Is there any way to get routine's parameter's user-defined datatype from
> system tables/views?
> I see there is a corresponding field in INFORMATION_SCHEMA.PARAMETERS view
,
> but it is said to be for future use...
--BEGIN PGP SIGNED MESSAGE--
Hash: SHA1
This works:
select parameter_name, data_type
from information_schema.parameters
where specific_name = 'procedure name'
Substitute your procedure name in the WHERE clause.
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
--BEGIN PGP SIGNATURE--
Version: PGP for Personal Privacy 5.0
Charset: noconv
iQA/ AwUBQlJLyIechKqOuFEgEQKibgCcD46kIxMkKQya
73lwxg0DrXcPIOoAn0Zr
W/GAuqaueyUtevN4hQnU1T0D
=/yvi
--END PGP SIGNATURE--
Labels:
corresponding,
database,
datatype,
field,
fromsystem,
microsoft,
mysql,
oracle,
parameter,
routine,
server,
sql,
tables,
user-defined,
viewsi
Subscribe to:
Posts (Atom)