Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mattt
Posting Yak Master
194 Posts |
Posted - 2008-06-25 : 10:19:52
|
| How come I can do this?select top 1 auditID from [jobs]..AdAudit order by auditID descBut not this?declare @var intselect @var = top 1 auditID from [jobs]..AdAudit order by auditID descIs there a workaround? |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-06-25 : 10:23:23
|
| declare @var intset @var=1Set rowcount @varselect auditID from [jobs]..AdAudit order by auditID descSet rowcount 0Other method is using dynamic sqlMadhivananFailing to plan is Planning to fail |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-06-25 : 10:27:57
|
select top 1 @var = auditID from [jobs]..AdAudit order by auditID descwhich is the same asSELECT @var = max(auditid)from [jobs]..AdAudit E 12°55'05.25"N 56°04'39.16" |
 |
|
|
mattt
Posting Yak Master
194 Posts |
Posted - 2008-06-25 : 10:33:20
|
| Thanks! |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-06-25 : 10:45:34
|
Well. I misunderstood the question MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|