SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Problem querying column containing an asterisk


Problem querying column containing an asterisk

Author
Message
gareth.bowen
gareth.bowen
SSC Rookie
SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)

Group: General Forum Members
Points: 34 Visits: 415
Hi I have a table with a column which is defined as a varchar that contains asterisks. If I query that column I get the expected results,
select col from tableA
e.g. 1308064*8
1522323*11

However, if I select the same column using a query with a join condition I get the following output:

Select col from tableA A
left join tableB B
on a.key = b.key

8.56E+17
8.61E+18

In fact I get the same output if I include a second column in the first query, e.g
Select key.col
from tableA

I'm running against a Sql2005 SP3 database.

Anyone got any ideas what is happening here or how to ensure I get the actual varchar value?
Lowell
Lowell
One Orange Chip
One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)

Group: General Forum Members
Points: 28359 Visits: 39959
garth i could not get a result to work the way you said; we would need something equivilent to this to test with:


With TableA ([key],col)
AS
(SELECT 1,'1308064*8' UNION ALL
SELECT 2, '1522323*11'
),
TableB ([key],col)
AS
(SELECT 1,'Some Stuff' UNION ALL
SELECT 2, 'Other Stuff'
)
Select A.col ,*
from tableA A
left join tableB B
on a.[key] = b.[key]





Lowell

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

David Webb-CDS
David Webb-CDS
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1576 Visits: 8586
How are you executing the query? Wouldn't be directly into Excel by any chance, would it?



And then again, I might be wrong ...
David Webb
gareth.bowen
gareth.bowen
SSC Rookie
SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)

Group: General Forum Members
Points: 34 Visits: 415
Hi David, I wasn't using Excel just SSMS.
David Webb-CDS
David Webb-CDS
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1576 Visits: 8586
As Lowell suggested, posting the table definitions and some sample data in the form of insert statements would help. Can you replicate this behavior in other tables or is it just this particular column? Is this a table or a view? Can you post some of the varchar values and the scientific notation values that correspond to them?



And then again, I might be wrong ...
David Webb
gareth.bowen
gareth.bowen
SSC Rookie
SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)

Group: General Forum Members
Points: 34 Visits: 415
Apologies to all, this was not a problem after all but 2 rogue rows in the data! I'd been looking at the data that long, that I'd confinced myslef there was something wrong going on.

Thanks for all the replies and sorry for wasting your time.

Merry Christmas to all

Gareth
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search