How to print uniqueidentifier or binary data type?

  • In MSDB, all job_ID are uniqueidentifier data type, sometimes Job_ID is binary datatype. I need to print 'job_ID: ' + cast(@job_ID as varchar(100)). It prints nothing...

    How could I convert and print the contents of Job_ID?

    thanks

    David

  • The following works for me:

    select 'job_ID: ' + cast(job_ID as varchar(100)) from sysjobs

    Also the following works:

    declare @job_id uniqueidentifier

    select top 1 @job_id = job_id from sysjobs

    print 'job_ID: ' + cast(@job_ID as varchar(100))

    Is it possible your variable @job_id is NULL? ie. you haven't fetched a value into it?


    Cheers,
    - Mark

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply