• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

How can I create GUID in store proecdure?

How can I create GUID in store proecdure? Example please.
0
musclejack
Asked:
musclejack
1 Solution
 
rafranciscoCommented:
DECLARE @GUID uniqueidentifier

SET @GUID = NEWID()

PRINT @GUID
0
 
NawalKishore1976Commented:
Return Types
uniqueidentifier

Examples
A. Use the NEWID function with a variable
This example uses NEWID to assign a value to a variable declared as the uniqueidentifier data type. The value of the uniqueidentifier data type variable is printed before the value is tested.

-- Creating a local variable with DECLARE/SET syntax.

DECLARE @myid uniqueidentifier

SET @myid = NEWID()

PRINT 'Value of @myid is: '+ CONVERT(varchar(255), @myid)

 

Here is the result set:

Value of @myid is: 6F9619FF-8B86-D011-B42D-00C04FC964FF

 

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now