[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 215
  • 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

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

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