Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 UNIQUEIDENTIFIER vs BINARY(16) JobID

Author  Topic 

jone0497
Starting Member

8 Posts

Posted - 2007-02-16 : 11:29:39
Hello,
I was wonder what the arguments were for using one over the other:
DECLARE @JobID BINARY(16)
vs
DECLARE @JobID UNIQUEIDENTIFIER

Both get used the same:
EXECUTE @ReturnCode = msdb.dbo.sp_add_job
@job_id = @JobID OUTPUT, ...

I have seen these both on sample TSQL code, along with it not even being declared and just being used as shown here.

Thanks,
JJ

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-02-16 : 11:36:03
Bort are 128 bit binary values, just formatted two different ways.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

jone0497
Starting Member

8 Posts

Posted - 2007-02-16 : 11:41:11
Are there any performance benefits to either format over the other?
Go to Top of Page

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2007-02-16 : 15:02:59
Performance should be exactly the same, its more in the intent of the two. Binary is generic, it can hold pretty much anything, uniqueidentifier can only hold GUIDs. Try this for example

declare @one binary(16)
declare @two uniqueidentifier
select @one = newid(), @two = newid()
select @one, @two
select @one = cast(getdate() as binary(16))--, @two = cast(getdate() as uniqueidentifier)
select @one, @two
Go to Top of Page
   

- Advertisement -