Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

Unexpected query results / dealing with wildcards

$
0
0

Hi all,

I have a Transact SQL query that I am trying to write, but am having difficulties.

I need to separate one field into three outputs, I can do that... that's not the problem.

Here is an example of my code, it is a part of my SELECT statement:

SQL
,LEFT(invoice_lines.item_no,6)AS[ParentSKU],SUBSTRING(invoice_lines.item_no,7,3)ASColor,RIGHT(invoice_lines.item_no,4)ASSize

The problem is, back before we started using a SQL server, our marketing and IT guy decided that it would be a good idea to construct the SKUs with the sizes having underscores in them (i.e. a size 7.5 shoe would be "_7.5". a size 6 shoe would be "___6".). Herein lies the problem...underscores as seen as wildcards in SQL from my understanding. The results I get are "7.5" and "_6".

How do I force the statement to just look at the value as a simple...


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>