SQLCMD seems to use a different code page

  • Odd one this.

    I use SQLCMD mode of SSMS extensively when managing major projects. This was I can get developers to code each procedure into a separate file, create rollback scripts, manage it using source control, and most of all, use the :r and :setvar commands to build install scripts that can run everything.

    This has worked perfectly for a long time until one of the developers noticed a peculiarity with a stored procedure. The procedure returns as one of it's fields a piece of text with a number prefixed with the £ symbol (e.g. "Remit by return £19.55").

    For example

    CREATE PROCEDURE [stp_testsymbol]

    AS

    SELECT 'This is the £ symbol';

    GO

    If I execute this and use sp_helptext to query it, there is no problem.

    If I switch to SQLCMD mode and execute the script, there is no problem.

    But, if I then save the script and execute it from another SQLCMD script using :r "C:\testscript.sql" what I end up with is this:

    SELECT 'This is the � symbol';

    Does anyone know of any way to stop this?


    ---------------------------------------
    It is by caffeine alone I set my mind in motion.
    It is by the Beans of Java that thoughts acquire speed,
    the hands acquire shaking, the shaking becomes a warning.
    It is by caffeine alone I set my mind in motion.

  • I couldn't find a solution to this, so I used a work around:

    CREATE PROCEDURE [stp_testsymbol]

    AS

    SELECT 'This is the ' + CHAR(163) + ' symbol';

    🙂

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

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