Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting an identity column in view

Status
Not open for further replies.

davideart

Programmer
Apr 4, 2001
55
IT
Hi all..that's my problem and i really hope some of you can help me.

I have to create a view selecting all fields from a table; plus, i'd like to insert an addictional column defined as an identity (or a random numeric value) so that i can create a sort of unique field for that view.
To explain better, I'd need something like:
Code:
select *, getdate() from table
but, instead of getdate() function, I'd need a function that insert unique numeric values (random or sequential indifferently)

Has any of you an idea?
Thank you in advance, bye
David
 
You could use this which gives a GUID value:

Code:
CREATE VIEW myview
AS

SELECT NEWID() AS pk, *
FROM mytable

--James
 
Hi James...thank you very much: the NEWID() function is more or less what i was looking for.

Thank you again for quick and precise reply, cheers!

David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top