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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Date problem

Author  Topic 

introlux
Starting Member

7 Posts

Posted - 2008-05-28 : 12:17:33
I am trying to retrieve data from MYSQL to the SQL Server but I keep recieving an error message.

Insert error, column 2('unsubscribe_date', DBTYPE_DBTIMESTAMP), status 6: Data overflow. Invalid character value for cast specification.

The format in the MYSQL field is DATE
The format in the SQL Server is smalldatetime

How will i manage to complete this command without changing anything in MYSQL tables.

Thanks

introlux

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-28 : 12:29:51
What's the dateformat of values coming from MySQL?
Go to Top of Page

introlux
Starting Member

7 Posts

Posted - 2008-05-28 : 12:31:15
2007-09-21
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-28 : 12:41:28
quote:
Originally posted by introlux

2007-09-21


Then i dont guess that could be a problem.have you tried using CAST or CONVERT before insertion?
Go to Top of Page

introlux
Starting Member

7 Posts

Posted - 2008-05-28 : 12:52:45
I am not sure to correct method to do it. I have tried the examples online but has not worked, which then this web site came up with good help offered by members. So im here to resolve this problem (hopefully fingers crossed)

introlux
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-28 : 12:56:59
quote:
Originally posted by introlux

I am not sure to correct method to do it. I have tried the examples online but has not worked, which then this web site came up with good help offered by members. So im here to resolve this problem (hopefully fingers crossed)

introlux


Can i see query you used?
Go to Top of Page

introlux
Starting Member

7 Posts

Posted - 2008-05-28 : 13:01:05
-----------------------Table creation------------------------------

CREATE TABLE [MaRSCHORPanel].[dbo].[unsubscribe_copy1]([Marsc_id] decimal(10,
0) NOT NULL,
[unsubscribe_date] smalldatetime NOT NULL, [email]
varchar(150) NOT NULL, [source_id] varchar(50) NOT NULL, [unsubscribe_id]
int NOT NULL)

--------------------------------------------------------------------

----------------------Taking data from other MYSQL------------------

select `Marsc_id`,`unsubscribe_date`,`email`,`source_id`,`unsubscribe_id` from `pyramid`.`unsubscribe`

---------------------------------------------------------------------

As far as i know, the command has to be put in the 1st part.

introlux
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-05-28 : 13:05:25
Try using CAST(unsubscribe_date as smalldatetime)
Go to Top of Page

introlux
Starting Member

7 Posts

Posted - 2008-05-28 : 13:18:50
Error message:

You have an error in your SQL syntax. Check the manual that corresponds to your version for the right syntax to use 'CAST(unsubscribe_date as smalldatetime)' at line 1
Go to Top of Page

introlux
Starting Member

7 Posts

Posted - 2008-05-29 : 03:53:11
any luck??
Go to Top of Page

introlux
Starting Member

7 Posts

Posted - 2008-05-29 : 05:03:40
Sorted out problem, changed from smalldatetime to DATETIME and it worked :-)

Thanks for all the support

introlux
Go to Top of Page
   

- Advertisement -