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
 General SQL Server Forums
 New to SQL Server Programming
 Increment order

Author  Topic 

petervarga
Starting Member

1 Post

Posted - 2008-03-18 : 09:20:53
Hi. I am new in sql and i need help for increment rows. This is my script
I worked in ms sql 2000
SELECT cool.Podchl,cool.Datumchl, cool.Textchl, cool.Timechl,
cast ((substring(cool.Datumchl,7,4)) as int ) as year,
cast ((substring(cool.Datumchl,4,2)) as int ) as month,
cast ((substring(cool.Datumchl,1,2)) as int ) as day,
cast ((substring(cool.Datumchl,13,2)) as int ) as hour,
cast ((substring(cool.Datumchl,16,2)) as int ) as min
FROM zih2.dbo.cool cool
WHERE (cool.Timechl<>'00')
ORDER BY year,month,day,hour,min

I need add new colum, where first colum will be order. I made it but after execute order by I have got 2,3,4,1,5... and i need 1,2,3,4,5,...

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-03-18 : 09:26:30
Not quite clear what you want.Are you ooking for column with autoincrementing values? If yes, use ROW_NUMBER() function if you're using SQL 2005
Go to Top of Page
   

- Advertisement -