Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alter column from datetime to bigint

Status
Not open for further replies.

nisha23

Programmer
Sep 23, 2003
19
US
command -(Alter table
alter column ...)
Can I change data type from datetime to bigint
as it is giving me error
Disallowed implicit conversion from data type datetime to data type bigint
 
Here's how I would do this. (There may be a better way)

1. Add a new column to the table of type BigInt
2. Update the column: Update Table Set MyNewField = convert(bigInt, MyDateField)
3. Drop the old column
4. Create the column with type BigInt
5. Copy data from Temp Column to Original Column
6. Drop the temp column table



-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top