Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
dcarva
Posting Yak Master
140 Posts |
Posted - 2005-08-12 : 15:04:36
|
| Hello,I have a table that has a "MachineStatus" column. This column is set to allow nulls. But when the customer upgrades to our new application, I need to set any NULL values in that column to '' and then change the column to NULL. How can I do this? I can't drop and re-create the column because it would delete the data. I looked at AlTER TABLE. I just need to remove the ALLOW NULL setting.Thanks!Danny |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-08-12 : 15:06:15
|
| UPDATE YourTable SET MachineStatus = '' WHERE MachineStatus IS NULLGOALTER TABLE YourTable ALTER COLUMN MachineStatus varchar(nn) NOT NULLGOTara |
 |
|
|
paulrandal
Yak with Vast SQL Skills
899 Posts |
Posted - 2005-08-12 : 15:07:37
|
| For example:UPDATE MyTable SET MachineStatus = N'NULL' WHERE MachineStatus IS NULLALTER TABLE MyTable ALTER COLUMN MachineStatus NVARCHAR(20) NOT NULLPaul RandalDev Lead, Microsoft SQL Server Storage Engine(Legalese: This posting is provided "AS IS" with no warranties, and confers no rights.) |
 |
|
|
dcarva
Posting Yak Master
140 Posts |
Posted - 2005-08-12 : 15:08:18
|
| ALTER COLUMN - Awesome! I overlooked it. |
 |
|
|
|
|
|