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)
 Max from Table

Author  Topic 

danasegarane76
Posting Yak Master

242 Posts

Posted - 2007-06-20 : 11:39:08
Hi all,
I am using this code to get the max from a table.How can I get value increatmented by 1
select isnull(max(fileid),0) from wms_trnrecoverydetails


Dana


nr
SQLTeam MVY

12543 Posts

Posted - 2007-06-20 : 11:42:20
select isnull(max(fileid),0) + 1 from wms_trnrecoverydetails

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

danasegarane76
Posting Yak Master

242 Posts

Posted - 2007-06-20 : 11:46:01
Oh So Simple.

Thanks Nigel
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2007-06-20 : 11:54:20
Note - if you are trying to get the next available value which you then insert then if you have a multi user system this would probably allow duplicate values.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -