
November 29th, 2004, 11:48 AM
|
|
Registered User
|
|
Join Date: Nov 2004
Location: Sacramento, California, USA
Posts: 13
Time spent in forums: 29 m 11 sec
Reputation Power: 0
|
|
|
Make sure you're reading your requirements correctly
You could just throw together some code like this that would do it:
Code:
DECLARE @new_id uniqueidentifier
SET @new_id = newid()
SELECT @new_id, column1, column2
FROM table
WHERE whatever = whatever_else
But you wouldn't be able to use that ID to reference that particular record again, nor would you have any way to store it inside the view.
You'd have to use the code accessing the record to keep track of this ID, which would be essentially unrelated to the data (breaking one of the rules of normality).
It really is a better idea to add a column to the table, or find some combination of columns that is unique to the record and coming up with a coding scheme based on the value of those columns.
Hope this helps,
Steve
|