How to generate a new Guid in stored procedure?

Viewed 103607

I currently have a stored procedure in which I want to insert new rows into a table.

insert into cars
(id, Make, Model)
values('A new Guid', "Ford", "Mustang")

So the primary key 'id' is a Guid. I know how to create a new Guid in C# code but within the stored procedure I'm unsure how to generate the new Guids for the primary key values.

5 Answers

In the format of the question (spot the pedant!)

insert into cars
  (id, Make, Model)
  values(NEWID(), "Ford", "Mustang")
Related