Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get a rownumber
Message
General information
Forum:
Microsoft SQL Server
Category:
Other
Title:
Miscellaneous
Thread ID:
01525672
Message ID:
01525782
Views:
31
>>>>>Hi All -
>>>>>
>>>>>I need to update a specific row within a table something like this:
>>>>>
>>>>>UPDATE mytable SET myfield = 10 WHERE (ROWNUMBER = 4)
>>>>>
>>>>>but I can't find a good way to identify the row. I've looked at ROW_NUMBER(), IDENTITY(), and RANK(), but none of them seem to fit. Could someone explain how to do this?
>>>>>
>>>>>Thanks
>>>>
>>>>You need a key somehow. This isn't VFP. What are the field values that make your 4th row unique? Make them the where clause.
>>>
>>>Thanks William.
>>>My table has a fixed number of rows so I just added another column with rownumber. It seems to work OK. I was just hoping to make it a little simpler with a function like RecordNo().
>>>
>>>Thanks for the clarification.
>>>
>>>And now my mantra "Why 'O Why can't MS make SQLServer/NET as easy as VFP?" They should get Calvin and Levy on the team.
>>
>>youre supposed to update on primary key.....
>
>Doesn't work here. The table is constructed entirely in code cell by cell. There is no PK. In effect the 'rank' column I added becomes the primary key.

So aside from your 'rank' column you have rows that are exact duplicates of other rows? If so, then your 'rank' column is effectively your primary key. You can certainly declare it the primary key in code. you don't have to declare the primary key, but it is good practice.

If you do not have exact duplicate rows (aside from the 'rank' column) then you can declare (or just assume) the primary key as a composite of those columns that will always produce a unique record.
____________________________________

Don't Tread on Me

Overthrow the federal government NOW!
____________________________________
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform