Problem inserting non Ascii characters through command file

  • Hi,

    I have created a command file in a database project in Visual Studio .NET that creates multiple stored procedures and runs a script to insert values.

    A strange problem occurs when the command file runs the script.  All non Ascii characters insert incorrectly into the tables.  For example, "£" becomes "ú".  When I run the script outside of the command file, however, all non Ascii values are inserted correctly.

    Below is an example of a part of the script:

    EXEC

    @ERROR= WW_SP_ADD_CONFIGURATION 'STRING','1','CURTYPE_GBP','£',10,@AdminID

    Below is the command file.  Any suggestions on how to have the command file insert non Ascii values correctly would be great.

    Thank you,

    Rachel

    @echo off

    REM: Command File Created by Microsoft Visual Database Tools

    REM: Date Generated: 3/25/2005

    REM: Authentication type: Windows NT

    REM: Usage: CommandFilename [Server] [Database]

    if '%1' == '' goto usage

    if '%2' == '' goto usage

    if '%1' == '/?' goto usage

    if '%1' == '-?' goto usage

    if '%1' == '?' goto usage

    if '%1' == '/help' goto usage

    osql -S %1 -d %2 -E -b -i "Stored Procedures\WW_SP_ADD_PROCESS.prc"

    if %ERRORLEVEL% NEQ 0 goto errors

    osql -S %1 -d %2 -E -b -i "Stored Procedures\WW_SP_ADD_ASSOC_GROUPS.sql"

    if %ERRORLEVEL% NEQ 0 goto errors

    osql -S %1 -d %2 -E -b -i "Stored Procedures\WW_SP_ADD_CONFIGURATION.sql"

    if %ERRORLEVEL% NEQ 0 goto errors

    osql -S %1 -d %2 -E -b -i "Stored Procedures\WW_SP_ADD_GROUP_RIGHTS.sql"

    if %ERRORLEVEL% NEQ 0 goto errors

    osql -S %1 -d %2 -E -b -i "Stored Procedures\WW_SP_ADD_MESSAGES.sql"

    if %ERRORLEVEL% NEQ 0 goto errors

    osql -S %1 -d %2 -E -b -i "Stored Procedures\WW_SP_ADD_OLAP.sql"

    if %ERRORLEVEL% NEQ 0 goto errors

    osql -S %1 -d %2 -E -b -i "Stored Procedures\WW_SP_ADD_OLAP_FIELDS.sql"

    if %ERRORLEVEL% NEQ 0 goto errors

    osql -S %1 -d %2 -E -b -i "Stored Procedures\WW_SP_ADD_REPORT_CRITERIA.sql"

    if %ERRORLEVEL% NEQ 0 goto errors

    osql -S %1 -d %2 -E -b -i "Stored Procedures\WW_SP_ADD_REPORT_MASTER.sql"

    if %ERRORLEVEL% NEQ 0 goto errors

    osql -S %1 -d %2 -E -b -i "Stored Procedures\WW_SP_ADD_REPORT_TYPE.sql"

    if %ERRORLEVEL% NEQ 0 goto errors

    osql -S %1 -d %2 -E -b -i "Stored Procedures\WW_SP_ADD_SECURITY_GROUPS.sql"

    if %ERRORLEVEL% NEQ 0 goto errors

    osql -S %1 -d %2 -E -b -i "Stored Procedures\WW_SP_ADD_SECURITY_MASTER.sql"

    if %ERRORLEVEL% NEQ 0 goto errors

    osql -S %1 -d %2 -E -b -i "Stored Procedures\WW_SP_ADD_STYLE.sql"

    if %ERRORLEVEL% NEQ 0 goto errors

    osql -S %1 -d %2 -E -b -i "Stored Procedures\WW_SP_ADD_STYLE_ATTRIBS.sql"

    if %ERRORLEVEL% NEQ 0 goto errors

    osql -S %1 -d %2 -E -b -i "Stored Procedures\WW_SP_ADD_TRANSFER_CODES.sql"

    if %ERRORLEVEL% NEQ 0 goto errors

    osql -S %1 -d %2 -E -b -i "Stored Procedures\WW_SP_ADD_TRANSLATE.sql"

    if %ERRORLEVEL% NEQ 0 goto errors

    osql -S %1 -d %2 -E -b -i "Stored Procedures\WW_SP_ADD_USER.sql"

    if %ERRORLEVEL% NEQ 0 goto errors

    osql -S %1 -d %2 -E -b -i "Stored Procedures\WW_SP_ADD_USER_ASSOC.sql"

    if %ERRORLEVEL% NEQ 0 goto errors

    osql -S %1 -d %2 -E -b -i "Stored Procedures\WW_SP_ADD_USER_GROUPS.sql"

    if %ERRORLEVEL% NEQ 0 goto errors

    osql -S %1 -d %2 -E -b -i "Stored Procedures\WW_SP_ADD_USER_PREFERENCES.sql"

    if %ERRORLEVEL% NEQ 0 goto errors

    osql -S %1 -d %2 -E -b -i "Stored Procedures\WW_SP_ADD_USER_RIGHTS.sql"

    if %ERRORLEVEL% NEQ 0 goto errors

    osql -S %1 -d %2 -E -b -i "Scripts\Initialize.sql"

    if %ERRORLEVEL% NEQ 0 goto errors

    goto finish

    REM: How to use screen

    :usage

    echo.

    echo Usage: MyScript Server Database

    echo Server: the name of the target SQL Server

    echo Database: the name of the target database

    echo.

    echo Example: MyScript.cmd MainServer MainDatabase

    echo.

    echo.

    goto done

    REM: error handler

    :errors

    echo.

    echo WARNING! Error(s) were detected!

    echo --------------------------------

    echo Please evaluate the situation and, if needed,

    echo restart this command file. You may need to

    echo supply command parameters when executing

    echo this command file.

    echo.

    pause

    goto done

    REM: finished execution

    :finish

    echo.

    echo Script execution is complete!

    :done

    @echo on

     

  • use isqlw instead of osql.

    You may have to specify -o in the syntax.

    isqlw /? for syntax detail.

  • isqlw -FA -o "OutANSI.txt" -S %1 -d %2 -E -b -i "Scripts\Initialize.sql" works perfectly.  Thanks!

    I also just discovered that I can keep the osql syntax if I save the script as a unicode script.

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

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