SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 UNIQUEIDENTIFIER vs BINARY(16) JobID
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jone0497
Starting Member

8 Posts

Posted - 02/16/2007 :  11:29:39  Show Profile  Reply with Quote
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

Sweden
30218 Posts

Posted - 02/16/2007 :  11:36:03  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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 - 02/16/2007 :  11:41:11  Show Profile  Reply with Quote
Are there any performance benefits to either format over the other?
Go to Top of Page

snSQL
Flowing Fount of Yak Knowledge

USA
1837 Posts

Posted - 02/16/2007 :  15:02:59  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.1 seconds. Powered By: Snitz Forums 2000