Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL CAST Help

Status
Not open for further replies.

CoSpringsGuy

IS-IT--Management
Aug 9, 2007
955
US
Not sure if this is an ok forum to post this question.

I need to use the Cast or Convert command so that I can link to another table. The following is the sql WITHOUT Cast or Convert and it works fine:
SELECT `Sheet1_`.`clt accct`, `Sheet1_`.`Debtor`, `Sheet1_`.`client code`, `Sheet1_`.`initial balance`
FROM `Sheet1$` `Sheet1_`

I need to cast the first field to text but get errors when trying the following methods
SELECT cast(`Sheet1_`.`clt accct` as varchar(20)),`Sheet1_`.`Debtor`, `Sheet1_`.`client code`, `Sheet1_`.`initial balance`
FROM `Sheet1$` `Sheet1_`

SELECT convert(varchar(2)),`Sheet1_`.`clt accct`), `Sheet1_`.`Debtor`, `Sheet1_`.`client code`, `Sheet1_`.`initial balance`
FROM `Sheet1$` `Sheet1_`

Any thoughts on what I am doing wrong?





_____________________________________
Crystal Reports XI Developer Version
Intersystems Cache 5.X ODBC connection

 
What I see is that you're not aliasing the Cast or Convert, so Crystal won't know what to call the field.

-Dell

A computer only does what you actually told it to do - not what you thought you told it to do.
 
Thanks for the response.

I agree that I should alias the cast statement but, and Im not sure if it is a Crystal feature or ODBC or something I should know about SQL, without the alias it will come back as Expression_ followed by a number. Your comment is not lost on me however that is not my issue here.
After doing some research aand many goole searches, this is apparently a problem with Excel (or the ODBC?) which does not recognize the convert or the cast command. At least thats the conclusion I came to. So my fix was to create a new column in the excel spreadsheet and use =text("cell",0) so that I could link it to the other database table. Thanks for your help

_____________________________________
Crystal Reports XI Developer Version
Intersystems Cache 5.X ODBC connection

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top