?
Solved

SQL Server 2008 Problems altering data type to Date

Posted on 2011-02-17
5
Medium Priority
?
418 Views
Last Modified: 2012-05-11
I have a very large table [MasterFinal] and it includes a column that has a datetime type named CallDate
There is also a Calltime field so I would like to Alter the CallDate to type Date like 01/01/2011
Can someone help me?
0
Comment
Question by:Mswetsky
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 57

Expert Comment

by:HainKurt
ID: 34920213
CallDate is already datetime! you want to remove time part?
do you want to convert it to date only? and put time part into Calltime?
do you have values in CallTime now? or is it empty...

\can you give a sample and tell us what are you trying to do here...
0
 
LVL 1

Author Comment

by:Mswetsky
ID: 34921082
I don't want to involve the Time column.
I was looking for a data type to cut the Datetime field down.
Is there a way to Alter Column?
0
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 34921940
use alter column

ALTER TABLE TABLENAME
ALTER COLUMN CALLDATE DATE
0
 
LVL 57

Accepted Solution

by:
HainKurt earned 2000 total points
ID: 34922810
here is the steps:

create table dt(
a int,
b datetime,
c time)

insert into dt(a,b) values (1,getdate()-0.745)
insert into dt(a,b) values (2,getdate()-0.123)
insert into dt(a,b) values (3,getdate()-0.445)

select * from dt

a      b      c
1      2011-02-17 03:24:27.230      NULL
2      2011-02-17 18:20:08.030      NULL
3      2011-02-17 10:36:27.230      NULL

update dt set c=b

select * from dt

a      b      c
1      2011-02-17 03:24:27.230      03:24:27.2300000
2      2011-02-17 18:20:08.030      18:20:08.0300000
3      2011-02-17 10:36:27.230      10:36:27.2300000

alter table dt alter column b date

select * from dt

a      b      c
1      2011-02-17      03:24:27.2300000
2      2011-02-17      18:20:08.0300000
3      2011-02-17      10:36:27.2300000
0
 
LVL 1

Author Closing Comment

by:Mswetsky
ID: 34926604
Thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Audit has been really one of the more interesting, most useful, yet difficult to maintain topics in the history of SQL Server. In earlier versions of SQL people had very few options for auditing in SQL Server. It typically meant using SQL Trace …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question