SUBSTRING question

From: Skip (anonymous_at_discussions.microsoft.com)
Date: 09/27/04


Date: Mon, 27 Sep 2004 08:12:04 -0700

I have a field that is made up of several important values
all in one string. (Location.Serial# + '-' + ID). I need
help seperating this field in a query. I can use Substring
to take everything to the right of the '-'. Can anyone
tell me how to use substring to parse the information to
the left of the '-'. If I enter a negative value for the
length I get an error. I have also tried using the Left
and Right functions but I can't get the results I need.
Right and Left don't like the '-' for some reason. If
anyone can help me to figure out a way to query the
characters to the left of a non interger I would
apprecitate it. Thanks in advance.



Relevant Pages

  • Re: LIKE, SUBSTRING, CONVERT how many resources??
    ... Pieter ... > If we were to query this table for all names beginning with 'J', ... > The situation gets worse with SUBSTRING and CONVERT... ... > This will return the same rows as the first query, ...
    (microsoft.public.sqlserver.server)
  • RE: Combining DISTINCT and SUBSTRING to dynamically build a query
    ... Combining DISTINCT and SUBSTRING to dynamically build a query ... | includes the distinct entries of the first two characters in each customer ... | SELECT DISCTINCT ) FROM tblCustomers ...
    (microsoft.public.sqlserver.ce)
  • Re: Query Criteria - Substring
    ... You will have to change the table and column names to suit ... >It seems so easy to do with criteria in a query, ... >substring of the field I've specified. ...
    (microsoft.public.access.queries)
  • Re: LIKE, SUBSTRING, CONVERT how many resources??
    ... CREATE TABLE MyTable (MyColumn VARCHAR(50)) ... CREATE CLUSTERED INDEX MyIndex ON MyTable ... If we were to query this table for all names beginning with 'J', ... The situation gets worse with SUBSTRING and CONVERT... ...
    (microsoft.public.sqlserver.server)
  • Query Criteria - Substring
    ... I'm trying to put together a query, comparing fields in ... It seems so easy to do with criteria in a query, ... substring of the field I've specified. ...
    (microsoft.public.access.queries)