Page 1 of 1

SQL SERVER select statement issue

Posted: Mon Aug 15, 2011 1:04 pm
by _chamak
select [PMT AMT] as PMT_AMT
[POOL #] as POOL
ect....
from table_name

this is the sample sql i am trying to read data using ODBC from sql server DB but having issue since one of the column is having # .

ODBC_GE_MONEY_INPUT,0: ODBC Info: SQLSTATE = 42S22: Native Error Code = 207: Msg = [IBM(DataDirect OEM)][ODBC SQL Server Driver][SQL Server]Invalid column name '"POOL ,[FICOScore'.

this is the error i am encountering. Can any one help me with this.

Thanks,

Keerthi

Posted: Mon Aug 15, 2011 2:11 pm
by suse_dk
# and $ sign are reserved signs in DataStage, so maybe it is possible to use the internal representation of the signs in your select statement?

http://publib.boulder.ibm.com/infocente ... d%65%22%20

http://publib.boulder.ibm.com/infocente ... d%65%22%20

Re: SQL SERVER select statement issue

Posted: Mon Aug 15, 2011 2:43 pm
by _chamak
Tried that but still no luck it shows the same error

Re: SQL SERVER select statement issue

Posted: Mon Aug 15, 2011 2:55 pm
by SURA
Did you tried either ' or " for that column?

'column_name' as col
or
"column_name" as col


DS User

Re: SQL SERVER select statement issue

Posted: Mon Aug 15, 2011 2:57 pm
by _chamak
yeah i tryed ['POOL #']....["POOL #"]....'POOL #'.... "POOL #"....as POOL
nothing works

Re: SQL SERVER select statement issue

Posted: Mon Aug 15, 2011 4:10 pm
by chulett
suse_dk wrote:# and $ sign are reserved signs in DataStage, so maybe it is possible to use the internal representation of the signs in your select statement?
_chamak wrote:Tried that but still no luck it shows the same error
Can you show us exactly what you tried? Did you notice that there are two underscores on each side of the replacement internal value?

Re: SQL SERVER select statement issue

Posted: Mon Aug 15, 2011 5:09 pm
by SURA
Ok, tell me which ODBC are you using?

ODBC connector / ODBC Enterprise?

If you tried with ODBC connector , then try to use ODBC Enterprise. It will work!

Just i tried the below query in ODBC Enterprise and it worked for me (But i tried it in windows os)

select "deptno#" as dept from dbo.emp1


DS User

Re: SQL SERVER select statement issue

Posted: Tue Aug 16, 2011 7:38 am
by _chamak
even tried it in ODBC enterprise still the same error

Re: SQL SERVER select statement issue

Posted: Tue Aug 16, 2011 1:08 pm
by jgreve
_chamak wrote:yeah i tryed ['POOL #']....["POOL #"]....'POOL #'.... "POOL #"....as POOL
nothing works
Based on the the following quote from this link: http://publib.boulder.ibm.com/infocente ... d%65%22%20
* The column names are used except when the external datasource column name contains a character that WebSphere DataStage does not support. In that case, two underscore characters replace the unsupported character.
It sounds like you should be able to use SQL like this:
not working: <s><e><l><e><c><t>< ><P><O><O><L><#><,>< ><F><I><C><O><S><c><o><r><e>< ><f><r><o><m>< ><G><E><_><M><O><N><E><Y]
might work: <s><e><l><e><c><t>< ><P><O><O><L><_><_><)><,>< ><F><I><C><O><S><c><o><r><e>< ><f><r><o><m>< ><G><E><_><M><O><N><E><Y>

The angle-brackets are meant to specifically emphasise the sequence of characters, I wanted to emphasise replacing POOL# with POOL__ and I wasn't sure how the two underscores would look once they posted.


Just for fun, could you post the actual SQL statement you're trying to use in addition to the error message?

Posted: Tue Aug 16, 2011 1:31 pm
by chulett
I think that doc is a little short on details. From what I recall, you replace a "#" with "__035__", that's two underscores on both sides of the internal value.

Ahh :-)

Posted: Tue Aug 16, 2011 5:31 pm
by jgreve
Ahh :-)
That makes sense.
chulett wrote:I think that doc is a little short on details. From what I recall, you replace a "#" with "__035__", that's two underscores on both sides of the internal value.