You are here: Re: set default value for a char column?? « MsSQL Server « IT news, forums, messages
Re: set default value for a char column??

Posted by Gert-Jan Strik on 09/25/06 19:13

All you have to do is make sure the default is specified as a string. In
other words, make sure you use single quotes to delimit the value.

Try this:

ALTER TABLE MyTable
ADD CONSTRAINT DF_MyTable_MyColumn
DEFAULT ('123-45-6789')
FOR MyColumn

HTH,
Gert-Jan


tlyczko wrote:
>
> I have a char(11) for SSN, and I would like to default it to
> 123-45-6789 so I can avoid having nulls in this column, and so I can
> easily find the rows in which I need to have a 'correct' SSN
> entered/updated.
>
> I tried using just 123-45-6789, and SQL2005 doesn't seem to be
> defaulting to this value, it seems to be keeping it as
> (((123)-(45))-(6789), and not placing it into this column when a new
> row is created....
>
> Is there some special way I must specify defaults for a char(11) field
> (Yes, I will include the dashes).
>
> Thank you,
> Tom

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация