Solved

SQL Server 2008 Problems altering data type to Date

Posted on 2011-02-17
5
416 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 55

Expert Comment

by:Huseyin KAHRAMAN
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 55

Accepted Solution

by:
Huseyin KAHRAMAN 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

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 …
I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

726 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