Data truncated if entered using stored procedure HELP

  • Hi All,

    Please give me sugestion coz I'm about to go crazy ..

    I pass some value using vb.net and using the profiler I can see that all value that are passed through, the parameters are there(so Vb.net is OK). However, the result of the execution, one of the column's data is truncated to one letter only.

    I tried to copy and paste the execution that were run (from profiler) and run it as normal query, it is also truncated.

    But where I do normal UPDATE statement using normal query, the data would be inserted correctly.

    please please shed some light !

     

    The store procedure is

    CREATE PROCEDURE UpdateCheckOut

    @userindexnow int,

    @outtime smalldatetime,

    @outreason varchar

    AS

    Update CheckInTable

    set timeout = @outtime,

    alasanpulang = @outreason

    where indexonly = @userindexnow

     

    The event in Profiler would be

    exec UpdateCheckOut @userindexnow = '70', @outtime = '8/18/2005 4:51:21 PM', @outreason = 'sick'

     

    But in the table after the query is ran, everything would be correct but the alasanpulang (the column to be filled with 'sick') only resulted with letter s

    which is the first letter of the @outreason parameter.

  • I have found (personal experience) that when you declare a variable as VARCHAR() without telling it HOW LONG then it will DEFAULT to VARCHAR(1).

    Try telling the system how long you want the VARCHAR(i.e. how wide is the column) and try re-running the code.



    Good Hunting!

    AJ Ahrens


    webmaster@kritter.net

  • yup all variables [n][var]char default to 1 when no lenght is specified.

  • YESS !!!!!!

    that's right !!!!!!

    Now it works Thank you very much people ! I really appreciate the help

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

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