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.
| Author |
Topic |
|
jcb267
Constraint Violating Yak Guru
291 Posts |
Posted - 2010-12-09 : 11:27:22
|
I am pulling a field called premiummonth - (datetime, not null) and trying to convert it to a varchar using this in my select clause:convert(varchar(10), PremiumMonth, 101) as PDtThis worked previously but now I am getting this error - Msg 245, Level 16, State 1, Line 10Conversion failed when converting the varchar value '11/01/2010' to data type int.Can anyone help?  |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2010-12-09 : 11:29:42
|
| It's not this that's causing the error.Looks like you are trying to return the result as an int.Maybe due to a union or inserting in to the wrong column of a table?==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
jcb267
Constraint Violating Yak Guru
291 Posts |
Posted - 2010-12-09 : 11:33:49
|
| How would I be trying to return the result as an int.?It worked yesterday....... |
 |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2010-12-09 : 11:37:44
|
| It's beacuse of something that happens after the select (or maybe it's a completely different column that's causing it).In itself this shouldn't cause that error.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
jcb267
Constraint Violating Yak Guru
291 Posts |
Posted - 2010-12-09 : 11:41:05
|
| Here is all of the code. I am relatively new to this, so please excuse me.....Would you mind taking a look at it to see if you can spot the problem?select convert(varchar(10), PremiumMonth, 101) as PDt, convert(varchar(10), InvoiceDate, 101) as IDt, SponsorId as SponID, SponsorName as SponName, PolicyNumber as PolNum, SubscriberId as SubID, MemberId as MemID, -- total subs case when billedpremiumamount > '0' then '1' else '0' end as SubFlag, LineOfBusiness as LOB, Program as Prog, BenefitPlan as BP, RateCode as RC, CoverageType as ContType, (convert(varchar(10), PremiumMonth, 101)+SponsorID+RateCode) as LINK, --to be used to link to actual data BilledPremiumAmount as BillAmtfrom PremiumBillingwhere InvoiceStatus = 'BILLED' and InvoiceDate = '11/01/2010' and -- begin period after actuals REMEMBER TO ADJUST Program = 'Commercial' and BilledPremiumAmount > '0' |
 |
|
|
jcb267
Constraint Violating Yak Guru
291 Posts |
Posted - 2010-12-09 : 11:54:15
|
| I got it to work. I was trying to concatenate 3 fields all of different data types. |
 |
|
|
|
|
|
|
|