hi,
can anyone help me,is it able to set the default value as null to the field in a table.by using this query
ALTER TABLE register
ALTER column functionalarea SET DEFAULT 'NULL'
i got a error in this query also.can anyone rectify it.
thank you
Loading
ShambhuPosted Mar 14, 2011, 6:22 AM
for boolean:
Column1 BIT default 0,
for int:
Column2 int default 1
for varchar:
CREATE TABLE A
(
A VARCHAR(2),
B VARCHAR(3) DEFAULT 'SHA'
)
INSERT INTO A (A) VALUES('A')
SELECT * FROM A
Tick the checkbox above "Do you like this Answer"...
Suthish NairPosted Feb 8, 2011, 1:54 PM
Micke BlomqvistPosted Feb 8, 2011, 1:25 AM
Is it so that the column has a default already or does it have any of the mentioned data types?
According to msdn, Microsoft states:
http://msdn.microsoft.com/en-us/library/aa275462(v=sql.80).aspx
DEFAULT
Is a keyword that specifies the default value for the column. DEFAULT definitions can be used to provide values for a new column in the existing rows of data. DEFAULT definitions cannot be added to columns that have a timestamp data type, an IDENTITY property, an existing DEFAULT definition, or a bound default. If the column has an existing default, the default must be dropped before the new default can be added. To maintain compatibility with earlier versions of SQL Server, it is possible to assign a constraint name to a DEFAULT.