-
Changing a Column datatype
Hello I am having a table
table1
col1 (bit)
and i want to changethe col1 type for smallint
col1 (smallint)
true will be = 1
and false = 0
how can i do it ??
thank you
-
-
--And may not be able to if (incompatible) data is already present
-
FOR MSSQL 2000:
--alter column from bit to smallint
ALTER TABLE table1 ALTER COLUMN col1 SMALLINT NULL (or NOT NULL)
existent 1 (true-bit) values become 1 (smallint)
existent 0 (false-bit) values become 0 (smallint)
--alter column from smallint to bit
ALTER TABLE table1 ALTER COLUMN col1 BIT NULL (or NOT NULL)
existent > 0 (smallint) values become 1 (true-bit)
existent 0 (smallint) values become 0 (false-bit)
existent < 0 (smallint) values become 1 (true-bit)
--HTH--
-
If data is originally bit, should be no incompatibilities when altering to smallint.
-
thank you
in my case it works, the conversion was ok
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|