Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to add record number in sqlserver
Message
 
 
To
21/07/2012 09:48:06
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01548942
Message ID:
01548954
Views:
79
>in vfp i do :
>replace all myfield with recno()
>
>and the command re-number the field.
>
>how can i do it in sqlserver ?

In SQL 2005 and up look at ROW_NUMBER function, e.g.
;with cte as (select myfield, row_number() over (order by SomeField) as NewNumber from myTable)

update cte set myField = NewNumber
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform