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:
01446021
Views:
30
>>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!

Thank you very much, Borislav.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform