I need to take the data from a table in the Database, in my case dbo.EventsCollage and create a View for it.
The View should contain all the records for table to which is based plus I should add a Column called Id of datatype uniqueidentifier.
A uniqueidentifier value (random generated) should be created automatically for every records display in the View
Here how I am creating the View
CREATE VIEW testView
AS
SELECT
x.Name
FROM dbo.EventsCollage as x;
Could you please point me out a sample of code?
Use
newId(). (Note: this will give you a new Id for each row each time you select)(DEMO – 1)
Or if you need each row having same uniqueidentifier everytime, try (Note: this will work only up to 100mil records)
(DEMO – 2)