Width for Procedure Parameters

  • Hi

    Should the width part be specified for the Procedure parameters?

    I have procedure that takes a couple of parameters for

    inserts. The integer value goes wholly but the varchar value

    gets only character. My procedure parameters do not have

    the width specified for them. Only the data type of the parameter

    is specified.

     

    Regards

    Ramkumar

  • From BOL

    varchar[(n)]

    When n is not specified in a data definition or variable declaration statement, the default length is 1. When n is not specified with the CAST function, the default length is 30.

    So, to answer your question, always specify the length, even if it is one, it is good practice and lazy not to do so. Besides, if Microsoft ever changed this default (unlikely, but you never know) then you would have trouble in the future.

     

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Short and simple, always provide the width with char, varchar and varbinary. And always set the precision and scale for numeric, decimal and so on.

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

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