Service Desk Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

SQL CAST statement error

Highlighted
Toyin_1
Occasional Contributor

SQL CAST statement error

Hi All

I am trying to amend the Data import ini file for HPoV. I have used the code below within the SELECT statement:

CAST([ImpactStatement] AS varchar).

The intention being to convert the impactStatement field from String Type to varchar type. However I keep getting the error below:

the SELECT statement includes a reserved word or an argument that is misspelled, or the punctuation is incorrect. ErrorNumber:5005.

Please help!

7 REPLIES
The Pike
Honored Contributor

Re: SQL CAST statement error

Which driver are you using?
Did you try running that as part of an sql statement directly on the database to get a hint of what is going on?

The Pike
Toyin_1
Occasional Contributor

Re: SQL CAST statement error

Thanks Pike for your response. I am using the Excel ODBC driver. I have attached the ini file. What i am trying to achieve is change the datatype of the IMPACTSTATEMENT field within the .ini file used to convert from Excel to XML. If I try to assign any string value longer than 255 characters to the field it gets truncated. I tried assigning a value from within the ini file an i still get the same result.

Your help is greatly appreciated and I also assigned you some points earlier.
Ken Briscoe
Honored Contributor

Re: SQL CAST statement error

Try CAST([Data].[Impact statement]....
instead of CAST(Data.Impact statement ....
My email is kenilian@bigpond.com.au
Toyin_1
Occasional Contributor

Re: SQL CAST statement error

Thanks for your response. However, i'm still getting the same error message.
Ken Briscoe
Honored Contributor

Re: SQL CAST statement error

Sorry can't help. It may be that CAST is not valid for the Excel driver - I've never used it in that context. I know not everything that works for SQL driver works in Excel driver in Data Exchange.
My email is kenilian@bigpond.com.au
Toyin_1
Occasional Contributor

Re: SQL CAST statement error

Thanks everyone for the help. I have now resolved the original problem. I found out that including the keyword DISTINCT in the SELECT statement causes fields longer than 255 characters to be truncated. So i just took out the DISTINCT keyword and bingo! Not sure why this is so though.
Toyin_1
Occasional Contributor

Re: SQL CAST statement error

Thanks everyone for the help. I have now resolved the original problem. I found out that including the keyword DISTINCT in the SELECT statement causes fields longer than 255 characters to be truncated. So i just took out the DISTINCT keyword and bingo! Not sure why this is so though.
//Add this to "OnDomLoad" event