Problem in table in SQL server 2008

Asked By 0 points N/A Posted on -
qa-featured

Hello,

I made a mistake in a Table (allowing 2 Not Nulls in there and I to take them off). I tried to take them off but the program won't let me. Anyidea?

Also I deleted a Table named xxx and when I create a new table also named xxx, it said the table already existed (it doesn't show xxx) How do I fix this problem?

Thanks.

SHARE
Answered By 0 points N/A #113879

Problem in table in SQL server 2008

qa-featured

The Alter Column statement will help. We use the same syntax for SQL Server 2005 and SQL Server 2008 but 2008 allows the sparse attribute to be changed.

ALTER TABLE table_name
DROP COLUMN column_nam

Remember:

  • Only the data type, sparse attribute (2008) and the Null able attribute of a column can be changed.
  • You cannot add a NOT NULL specification if NULL values exist.
  • In order to change or add a default value of a column, you need to use  Add/Drop Constraint.
  • In order to rename a column, you must use sp_rename
Answered By 0 points N/A #113881

Problem in table in SQL server 2008

qa-featured
Thanks Bonifacekemiru,
 
I altered the table using the command you posted ALTER TABLE [ database_name. [ schema_name ]. | schema_name.] table_name {ALTER COLUMN column_name { [type_schema_name.] type_name [({precision [scale] | max | xml_schema_collection } ) ] [ COLLATE collation_name ] [ NULL | NOT NULL ] [ SPARSE ] | {ADD | DROP } { ROWGUIDCOL | PERSISTED | NOT FOR REPLICATION | SPARSE } } | [ WITH { CHECK | NOCHECK } ] | DROP { [ CONSTRAINT ] constraint_name [ WITH ( [ ,…n ] ) ] | COLUMN column_name } [ ,…n ]. Done, I take them off! Thank you very much!

Related Questions