using ' within a Unicode sting

  • Sure this is a simple, and probably stupid question but I need help with the following;

    I run the following to show all jobs

    use msdb

    go

    sp_help_job

    This returns all jobs. one of the jobs includes single quotes. For example;

    Daily 'full' backup

    I then want to run;

    use msdb

    go

    sp_help_job

    @job_name = N'Daily 'full' backup',

    @job_aspect = N'all'

    However it failes due to the single quotes. If for example the job was called;

    Daily full backup

    The SQL executes correctly. I have managed to work around this by using @job_id instead of @job name but would like to understand why this didn't work, is there a reason or way to using single quotes.

  • As far as I know no not using single quotes - you need to use double quotes.

    use msdb

    go

    sp_help_job

    @job_name = N'Daily ''full'' backup',

    @job_aspect = N'all'

    ==========================================================================================================================
    A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila. Mitch Ratcliffe

  • Thanks, I thought I tried that, but obviously had a typing error somewhere. Just tried again and that worked. Told you it was a stupid question.

    Thanks for the prompt reply.

  • Not a stupid question at all! 🙂

    Your welcome

    Andy

    ==========================================================================================================================
    A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns and tequila. Mitch Ratcliffe

Viewing 4 posts - 1 through 3 (of 3 total)

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