column-defaults

FluentNHibernate - Setting default value for DB columns (SQL Server)

Hi everyone, does anyone know a way how I could set through mapping the default value of a column so for e.g. when I generate DB from mappings I would have DateTime column having getdate() as default value? I tried so far this (looks exactlly like what I need) but it doesn't work this.Map(x => x.LastPersistedOn, "DateModified") ...

Script to generate default values for not columns with no defaults specified in SQL Server

I have a MySQL database that I am migrating to SQL Server. The application that references the database breaks when I run it against SQL Server because SQL Server does not offer the implicit defaults that MySQL offers. I wanted to see if there is a way to generate script that would force defaults on all NOT Null columns that do not have...

Should a database table have default values?

I was having a discussion with a developer at work on the issue of should a table use default values. Is there a hard and fast rule on this or is it a gray area in best practices? ...

Is there a way to conditionally use default column values in an INSERT..SELECT statement?

I've got code similar to the following in a stored procedure that inserts a row into a table, I'd like to set the last column (FieldD) to @prmSomeValue unless it is null, otherwise just use the default value defined for that column. IF (@prmSomeValue IS NULL) INSERT INTO MyTable (fieldA,FieldB,FieldC) SELECT A,B,C FRO...