|
Subject:
|
Moving date from one column to another
|
|
Posted By:
|
mattastic
|
Post Date:
|
10/4/2005 6:23:54 AM
|
Hi,
I need to change a varchar into a smalldatetime datatype.
Problem is my db has 1500 records, so i'm trying to create a new column with the smalldatetime datatype and copy all the data from the old column into here.
Can anybody tell me how to do this in sql server?
I've tried altering the table in design view, but it won't let me save it.
TIA
|
|
Reply By:
|
SqlMenace
|
Reply Date:
|
10/4/2005 7:25:13 AM
|
alter table Tablename ADD newdatecolumn smalldatetime NULL Go update Tablename set newdatecolumn =convert(smalldatetime,Oldvarcharcolumn) where isdate(Oldvarcharcolumn) =1 go
something like this should do it(untested)
http://sqlservercode.blogspot.com/
|
|
Reply By:
|
mattastic
|
Reply Date:
|
10/6/2005 3:16:19 PM
|
Thanks
|