Solved

SQL Server 2008 Problems altering data type to Date

Posted on 2011-02-17
5
388 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
  • 2
  • 2
5 Comments
 
LVL 51

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:ewangoya
ID: 34921940
use alter column

ALTER TABLE TABLENAME
ALTER COLUMN CALLDATE DATE
0
 
LVL 51

Accepted Solution

by:
HainKurt earned 500 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
There have been several questions about Large Transaction Log Files in SQL Server 2008, and how to get rid of them when disk space has become critical. This article will explain how to disable full recovery and implement simple recovery that carries…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

896 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now