Default value gets changed

  • Hello,

    I have a table with a field called Category, type of varchar(15), default value is '000000000000000'

    I just noticed it will get automatically changed to ((0.))

    Why and how to fix it?

    Thanks.

  • I can't try it in here, but have you tried to assign the default value to REPLICATE( '0', 15)?

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • i couldn't duplicate the behavior yet; the tables i scripted out get teh default value with all zeros, whether in the constraint definition, the scripting of the table or in the data if i add rows.

    where are you seeing the default value? when you script the table, or somewhere else?

    i tested with 2005,R2 and 2012 so far.

    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!

  • if you are seeing it in the data values , it could be some process is sending a value for the column with the default; values inserted take precendence over the default value, of course.

    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!

  • Luis Cazares (8/10/2012)


    I can't try it in here, but have you tried to assign the default value to REPLICATE( '0', 15)?

    Thank you! It works!

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

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