View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
K Dales[_2_] K Dales[_2_] is offline
external usenet poster
 
Posts: 1,163
Default Convert Format of SQL Data

Thanks for pointing this out: I don't work directly with T-SQL so I was not
aware of this limitation; I did mention that the actual formula would be
dependent on the implementation of SQL used. However any formula accepted by
T-SQL should work, and I am pretty sure there must be some formula that will
yield the proper result. There must be an IF statement that would do the
trick, but I would need to study up on the details of T-SQL function syntax
to get it right.

K Dales

"onedaywhen" wrote:


Wayne Wengert wrote:
SELECT COLUMN1, COLUMN2, COLUMN3, (COLUMN4=1) AS 'NEWNAME', ...

FROM
TABLENAME WHERE...


The problem was when I was trying to create
the new column in the SQL statement as described


I think there is a fundamental problem with this request: SQL has no
boolean data type. I don't think that

(COLUMN4=1) AS 'NEWNAME'

will have the effect the poster expects i.e. this will not coerce the
result to a boolean.

Practically speaking, you can't cast as boolean on the server side
because T-SQL lacks an appropriate data type and you can't cast in the
SQL on the client side because MS Query's implementation of SQL AFAIK
lacks any cast or conversion functions. So I think you need to do some
post-import conversion within Excel e.g. using a 'helper' column or
VBA.

Jamie.

--