Is there a way to set some column of each row in a table to some unique value e.g.
update mytable set myCol=rownum()
using SQL (not T/SQL) on SQL Server 2000.
I can’t touch the schema but I do have a spare column or two.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Provided that you have a primary key, you can generate a unique value by counting rows. For example (replace
#twith your table’s name):If you have a
varchar(36)or larger, you can generate GUID’s, which are guaranteed to be unique:If you have neither, you can use a variable. This technique is frowned upon because it’s not set based, but it works pretty well: