Thursday, March 22, 2012

drop the time

I have a field in my table that is set as DATETIME
The data that gets imported to it is a text file and has teh data with teh
time.
for example, 1/1/2006 4:57:12 PM
I want to get rid of teh time part
How can I make it so the data that I already have in the table will drop teh
time?
Hi
In a SQL Server datetime field you will always have a time part even if you
don't specify the time it will default to midnight (00:00.000).
You don't say how the data is imported and if that is the only way the
column gets populated?
If you use DTS to load the data, you could use an activeX transform to
truncate the datetime field before it is inserted. If you use BCP/BULKINSERT
you can specify a format file that splits off the time and ignores it.
Another method is to load the data into a staging table and manipulate it
from there whilst it is being inserted into the final destination. You could
also use an instead of trigger (but you would need to make sure that it fires
for your bulk insert), or possibly have a computed column that truncates the
datetime.
John
"Johnfli" wrote:

> I have a field in my table that is set as DATETIME
> The data that gets imported to it is a text file and has teh data with teh
> time.
> for example, 1/1/2006 4:57:12 PM
> I want to get rid of teh time part
> How can I make it so the data that I already have in the table will drop teh
> time?
>
>
|||ummm, hmmmm, ok, so how do I do any of teh items you mentioned?
I have DTS setup as teh text file is ftp'd to us. Teh time is included in
the text file and teh people sending it to us are not interested in dropping
off teh time portion.
"John Bell" <jbellnewsposts@.hotmail.com> wrote in message
news:CCF11FA2-4E88-4642-8242-AEA7213D590A@.microsoft.com...[vbcol=seagreen]
> Hi
> In a SQL Server datetime field you will always have a time part even if
> you
> don't specify the time it will default to midnight (00:00.000).
> You don't say how the data is imported and if that is the only way the
> column gets populated?
> If you use DTS to load the data, you could use an activeX transform to
> truncate the datetime field before it is inserted. If you use
> BCP/BULKINSERT
> you can specify a format file that splits off the time and ignores it.
> Another method is to load the data into a staging table and manipulate it
> from there whilst it is being inserted into the final destination. You
> could
> also use an instead of trigger (but you would need to make sure that it
> fires
> for your bulk insert), or possibly have a computed column that truncates
> the
> datetime.
> John
> "Johnfli" wrote:
|||Hi
I assume it is the same DTS package that will load the file?
Check out http://www.sqldts.com/default.aspx?279,4 on how to use the
ActiveX transform. You will need to use the left function on the source
column to just insert the date part.
John
Johnfli wrote:[vbcol=seagreen]
> ummm, hmmmm, ok, so how do I do any of teh items you mentioned?
> I have DTS setup as teh text file is ftp'd to us. Teh time is included in
> the text file and teh people sending it to us are not interested in dropping
> off teh time portion.
>
>
> "John Bell" <jbellnewsposts@.hotmail.com> wrote in message
> news:CCF11FA2-4E88-4642-8242-AEA7213D590A@.microsoft.com...
|||cool, I will give it a shot.
Thank you
"John Bell" <jbellnewsposts@.hotmail.com> wrote in message
news:1143826579.603455.255570@.g10g2000cwb.googlegr oups.com...
> Hi
> I assume it is the same DTS package that will load the file?
> Check out http://www.sqldts.com/default.aspx?279,4 on how to use the
> ActiveX transform. You will need to use the left function on the source
> column to just insert the date part.
> John
> Johnfli wrote:
>

No comments:

Post a Comment