Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Concatinating columns

Author  Topic 

GavinD1977
Yak Posting Veteran

83 Posts

Posted - 2006-08-08 : 06:07:42
Hello all.

I am taking details from a linked server file (.XLS file). Two of the fields in this file are STARTTIME and STARTDATE.

The problem I have is that these have to be imported into a SQL table, but only into one column of type DATETIME. The column name is STARTDATE. I really have no idea on how to go about this. Any ideas would be greatly appreciated.

Thanks.

Wanderer
Master Smack Fu Yak Hacker

1168 Posts

Posted - 2006-08-08 : 06:13:51
well, you want to get them into the format: "CCYY-MM-DD HH:MM:SS.mmm" - the last micro seconds are optional. Depending on the data you have, that may be as simple as: StartDate+' '+StartTime, or you may have to do a bit of formatting.

how are you trying to insert the data?


*##* *##* *##* *##*

Chaos, Disorder and Panic ... my work is done here!
Go to Top of Page

GavinD1977
Yak Posting Veteran

83 Posts

Posted - 2006-08-08 : 06:19:20
Hi thanks for the reply. Have managed to get it going though. Used the following:

INSERT INTO @TEMP_TABLE(STRATIME,
FINISHTIME)
SELECT STARTDATE + STARTTIME, --concatenate these two columns
FINISHDATE + FINISHTIME --concatenate these two columns
FROM mockdownload_dd...['Learning and Development$']
Go to Top of Page

Wanderer
Master Smack Fu Yak Hacker

1168 Posts

Posted - 2006-08-08 : 08:15:00
glad to hear it. Interesting that the contatenation didn't need the space.

*##* *##* *##* *##*

Chaos, Disorder and Panic ... my work is done here!
Go to Top of Page

GavinD1977
Yak Posting Veteran

83 Posts

Posted - 2006-08-08 : 08:46:22
I can only assume its beacue it into a DATETIME datatype :)
Go to Top of Page
   

- Advertisement -