Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Binding Checkbox to nchar column
Message
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Versions des environnements
Environment:
C# 2.0
Divers
Thread ID:
01445996
Message ID:
01446018
Vues:
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!
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform