Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


To insert varchar records in datetime field


To insert varchar records in datetime field

Author
Message
sqlstud
sqlstud
SSC Journeyman
SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)

Group: General Forum Members
Points: 99 Visits: 237
Hi,

I have table "Trial1"

One of the columns is
DATERECEIVED DATETIME NULL

Loading data from Excel to staging table using ssis 2005.

Datareceived column contains data as below

17/12/2010
18/12/2011
DECLINED
NULL

I need to load the data as it is. But thing is that, datatype is datetime..

We can modify the column as varchar...

But i need to know whether is it possible to load the data whatever present in the excel?

Regards
SqlStud
Sean Lange
Sean Lange
SSCoach
SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)SSCoach (16K reputation)

Group: General Forum Members
Points: 16680 Visits: 17038
sqlstud (10/10/2012)
Hi,

I have table "Trial1"

One of the columns is
DATERECEIVED DATETIME NULL

Loading data from Excel to staging table using ssis 2005.

Datareceived column contains data as below

17/12/2010
18/12/2011
DECLINED
NULL

I need to load the data as it is. But thing is that, datatype is datetime..

We can modify the column as varchar...

But i need to know whether is it possible to load the data whatever present in the excel?

Regards
SqlStud


Well it sort of depends on what you want. You currently have a datetime column but obviously "DECLINED" isn't going to work there. If you want to keep your datetime datatype (which I strongly recommend) then you probably need to make that NULL. If you want to maintain the data exactly as it is excel you will have to change to a varchar column.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
sqlstud
sqlstud
SSC Journeyman
SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)

Group: General Forum Members
Points: 99 Visits: 237


Well it sort of depends on what you want. You currently have a datetime column but obviously "DECLINED" isn't going to work there. If you want to keep your datetime datatype (which I strongly recommend) then you probably need to make that NULL. If you want to maintain the data exactly as it is excel you will have to change to a varchar column.



Thanks Sean..

I have changed the datatype to Varchar....

Please find the attachement.

While make a preview in OLEDB Source the data in the date column is displayed as NULL. But in excel sheet, it is "DECLINED".

Could you please give me the solution?

Regards
SqlStud
Attachments
Data Error.jpg (2 views, 45.00 KB)
Phil Parkin
Phil Parkin
SSCrazy Eights
SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)

Group: General Forum Members
Points: 8414 Visits: 19517
sqlstud (10/10/2012)


Well it sort of depends on what you want. You currently have a datetime column but obviously "DECLINED" isn't going to work there. If you want to keep your datetime datatype (which I strongly recommend) then you probably need to make that NULL. If you want to maintain the data exactly as it is excel you will have to change to a varchar column.



Thanks Sean..

I have changed the datatype to Varchar....

Please find the attachement.

While make a preview in OLEDB Source the data in the date column is displayed as NULL. But in excel sheet, it is "DECLINED".

Could you please give me the solution?

Regards
SqlStud


I am with Sean - it's 100 times better to keep your dates in a datetime column and do something else with the DECLINED info - perhaps create another column to hold 'status', or whatever, and use that.


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
Phil Parkin
Phil Parkin
SSCrazy Eights
SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)SSCrazy Eights (8.4K reputation)

Group: General Forum Members
Points: 8414 Visits: 19517
Your Excel column is holding mixed datatypes, so you'll need to bring in the column as string and add IMEX=1 to the Excel connection string (Google it for details).


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
sqlstud
sqlstud
SSC Journeyman
SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)

Group: General Forum Members
Points: 99 Visits: 237
Phil Parkin (10/11/2012)
Your Excel column is holding mixed datatypes, so you'll need to bring in the column as string and add IMEX=1 to the Excel connection string (Google it for details).


Thanks Phil...

I added IMEX=1 to the connection string..

But it displayed the error in OLEDB Source as



Error: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "Src_Product" failed with error code 0xC0202009. There may be error messages posted before this with more information on why the AcquireConnection method call failed.

Regards
Sqlstud
sqlstud
sqlstud
SSC Journeyman
SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)SSC Journeyman (99 reputation)

Group: General Forum Members
Points: 99 Visits: 237
It is solved..

i made change in the connection string

Data Source=<path\xlsx filename>;Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties="Excel 12.0;HDR=YES;IMEX=1";

Thanks to all

Regards
Sqlstud
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search