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

Assigning Select NewID() to variable in SQL

Dear Experts,

I'm trying to write a stored procedure and require a GUID. I know that SELECT NewID() will return a GUID, but how can I assign this value to a variable within my stored procedure?

Thanks

Nick
0
nkewney
Asked:
nkewney
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
declare @nid uniqueidentifier
set @nid = NEWID()

0
 
nkewneyAuthor Commented:
Simple as that - thanks !
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

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