Reply to Re: UPDATE on a column with a set default

Your name:

Reply:


Posted by David Portas on 01/30/06 23:01

Mike Husler wrote:

> If we have a column with a default value set, say GETDATE( ), how can we
> assure that value is reset on an UPDATE (not an INSERT) without changing
> the client code that does the updating?
> I'd rather stay away from triggers, etc if possible.
>
> Thanks,
> Mike Husler

If you actually put UPDATEs in client code then you are certainly
making life difficult for yourself. Had you used a stored procedure for
data access you could just have modified the proc. Any good reason why
you aren't using procs?

Otherwise I think you'll have to use a trigger or put the DEFAULT
keyword in your UPDATE:

UPDATE your_tbl
SET col = DEFAULT ;

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--

[Back to original 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

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