x

Datatypes DT_WSTR and DT_Date are incompatable for binary operator + error in ssis expression

Hi,

am using an sql query in my expression where i need to fetch the data based on the date. For example this is the query am using in varibale. **select from employee where m_dtadddate = "+ @[System::StartTime] +"' AND m_eid='"+@[User::eid]+"'.
When i evaluate this expression it is showing error like
Datatypes DT_WSTR and DT_Date are incompatable for binary operator +* how to avoid this error

more ▼

asked May 25, 2012 at 07:06 AM in Default

avatar image

kumar537
0 2 2 2

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

Since it is the error at evaluation time, the root cause is that the Expression is of data type DT____WSTR, whereas the @[System::StartTime] is of data type DT___Date. To rectify this, you need to explicitly convert the data type of @[System::StartTime] to DT_WSTR. The simplest way could be

 "select * from employee where m_dtadddate = '"+ (DT_WSTR, 25) @[System::StartTime] +"'..... 

But this could lead to date conversion issues. Based upon your source/destination, you may need to format the date string accordingly by using date-time functions etc..

Moreover, Thomas Rushton's suggestion is absolutely correct. You could be prompted a run time error (Not at the expression evaluation time) for the missing single quote. So please modify the expression as advised.

more ▼

answered May 28, 2012 at 01:35 PM

avatar image

Usman Butt
13.9k 6 13 21

(comments are locked)
10|1200 characters needed characters left

It looks to me as though you're missing a '

You have:

 ...WHERE m_dtadddate = " + @[System::StartTime]+ "' AND...

Shouldn't that be:

 ...WHERE m_dtadddate = '" + @[System::StartTime] + "' AND...

?

more ▼

answered May 25, 2012 at 10:19 AM

avatar image

ThomasRushton ♦♦
40.3k 20 49 53

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x1152

asked: May 25, 2012 at 07:06 AM

Seen: 4884 times

Last Updated: May 28, 2012 at 01:40 PM

Copyright 2016 Redgate Software. Privacy Policy