default-constraint

SQL Server 2005: When copy table structure to other database "CONSTRAINT" keywords lost

Snippet of original table: CREATE TABLE [dbo].[Batch]( [CustomerDepositMade] [money] NOT NULL CONSTRAINT [DF_Batch_CustomerDepositMade] DEFAULT (0) Snippet of copied table: CREATE TABLE [dbo].[Batch]( [CustomerDepositMade] [money] NOT NULL, Code for copy database: Server server = new Server(SourceSQLServ...

How to add a default value to an already existing column?

I have an existing column in my SQL Server database. I have tried about everything I can think of but can not get a default value to be added to the column. What works in every other database is alter table mytable alter column mycolumn set default(now()) --mycolumn is a datetime How do I do this in SQL Server? The error I get f...

Unable to set a URL as Default value in MySQL

Hi all, I am using phpMYAdmin to set a URL as a Default Value to a Field of a Table in MySQL database, but of no luck. The URL is like this one: http://www.kaboodle.com/hi/img/c/0/0/b2/9/AAAADMEBXEUAAAAAALKWPw.jpg Here is the Table field structure: {varchar(255), utf8_general_ci, Not Null} ...

default a column with empty string

Is there a way, via a SQL statement, to ensure a column's default value is an empty string '' instead of NULL? ...

mysql "datetime NOT NULL DEFAULT '1970-01-01' " gets turned to 0000-00-00 00:00:00

I have a column created as `date_start` datetime NOT NULL DEFAULT '1970-01-01' However when I upload data from a CSV file with the LOAD DATA command with a blank entry for date_start the value saved is 0000-00-00 00:00:00 ? ...