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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 [Resolved] Output contains a "Seq" column

Author  Topic 

snufse
Constraint Violating Yak Guru

469 Posts

Posted - 2011-08-29 : 14:28:56
When running following query I get ad additional column by the name of "Seq". Is there a way to avvoid that. I need to the put query result into a temp table. If not, how should I define this field?
Thank you.

SET @SQLSTRING = 'SELECT *
FROM
(
SELECT *,ROW_NUMBER() OVER (PARTITION BY SHKCOO,SHDOCO ORDER BY SHUPMJ DESC, SHTDAY DESC) AS Seq FROM OPENQUERY( AS400SRV_MSDASQL,
''select
shkcoo,
shdoco,
shdcto,
shmcu,
shan8,
shshan,
shaft,
wajobn,
shurcd,
shupmj,
shtday,
case when shupmj > 0 then date(digits(decimal(shupmj + 1900000,7,0))) else Null end as date_field,
case when substring(shtday,1,2) < 25
then concat(rtrim(char(substring(shtday,1,2))),CONCAT('''':'''',CONCAT(rtrim(char(substring(shtday,3,2))),Concat('''':'''',(rtrim(char(substring(shtday,5,2))))))))
else
concat(rtrim(char(substring(shtday,1,1))),CONCAT('''':'''',CONCAT(rtrim(char(substring(shtday,2,2))),Concat('''':'''',(rtrim(char(substring(shtday,4,2))))))))
end as time_field
from VGISOEDTA.F42019 as f1
left join (select distinct wajob, wajobn
from VGIWRQLIB.WRQASI)
as f2 on f2.wajob = f1.shvr01
where concat(shupmj,shtday) >= ''''' + @JdeTimeStamp + '''''
order by shkcoo,
shdoco ''))t WHERE Seq = 1'

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2011-08-29 : 14:45:53
Specify the column list you actually want to select, ommitting the Seq column.
Go to Top of Page

snufse
Constraint Violating Yak Guru

469 Posts

Posted - 2011-08-29 : 17:01:00
Got it. Thank you.
Go to Top of Page
   

- Advertisement -