SQL Task only passing first character of string to procedure

  • I've created an ADO.Net connection to a SQL 2005 instance and am using a Execute SQL Task to pass two parameters. FileName (ie. aadc_test) and FilePath (ie. \\\\remoteserver\\directory) to a procedure.

    The first parameter is defined as string (255) and the second as string (1000) in both the task and the database has those fields as nvarchar(255) and nvarchar(1000) respectively.

    When the procedure runs it will insert the filename and path into the database but ONLY THE FIRST CHARACTER. So I'll get "a" and "\" in my fields.

    Can anyone tell me why I'm only getting the first character of my strings?

    Thanks,

    Erin

  • What are the parameters defined as in the stored proc definition?

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • a parameter declared like DECLARE @var NVARCHAR or DECLARE @var2 VARCHAR has a size of ONE character...I think that's what Phil is going after...bad definition in the Stored procedure.

    you would want to explicitly define the size, if that's the case. @var NVARCHAR(255) or whatever is appropriate.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Booyah, Lowell! You hit it. I forgot to define the size of my stored proc variables.

    Good catch!

  • Lowell (3/4/2013)


    --

    ..I think that's what Phil is going after...bad definition in the Stored procedure.

    --

    It was indeed 🙂

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Erin Ramsay (3/4/2013)


    Booyah, Lowell! You hit it. I forgot to define the size of my stored proc variables.

    Good catch!

    IIRC, that maximum size for a DOS Path is 512 bytes. Not sure what it is for a UNC but I'd bullet proof the code a bit by making the variables on both ends with a width of at least 512 or maybe even 1024.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 6 posts - 1 through 5 (of 5 total)

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