Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Binding Checkbox to nchar column
Message
General information
Forum:
ASP.NET
Category:
Forms
Environment versions
Environment:
C# 2.0
Miscellaneous
Thread ID:
01445996
Message ID:
01446018
Views:
29
>Then, before they put handcuffs on me for violating the forum etiquette <g>, quick question. In order to change the column in SQL Server from char to bit and not to lose the existing values, I would have to create a temp column to hold the values, right?

Yep,
Something like this (NOT TESTED!!!!)
ALTER TABLE TableName ADD TempColumn bit NULL
GO
UPDATE TableName SET TempColumn = CASE WHEN TheCharColumn = 'A'
                                            THEN 1
                                       WHEN TheCharColumn = 'I'
                                            THEN 0
                                  ELSE NULL END
GO
ALTER TABLE TableName DROP COLUMN TheCharColumn
GO
EXEC sp_rename @objname = 'TableName.TempColumn',  @newname = 'TheCharColumn', @objtype = 'COLUMN'
GO
AGAIN!!!
NOT TESTED!
Just have a pretty good backup first!
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform