CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2002
    Location
    Jordan
    Posts
    30

    select range between letters

    Visual Basic 6 Sp5
    SQL Server 2000
    --------------------------
    i want to make sql select to select items between two words like

    select * from items where itemno >=ab and itemno<= dr

    itemno is nvarchar(15)

    but these not give the correct values

    Is there any way to solve these to be able to select between two letters or numbers value

    Thanks

  2. #2
    Join Date
    Oct 2001
    Location
    Melbourne, Australia
    Posts
    576

    Re: select range between letters

    1. put strings in single quotes
    2. try using a wildcard. i.e. WHERE itemno >= 'ab*'
    (I can't remember if wildcard is * or % in SQL Server)

    how big is your table though? i fear that the above would be slow on big tables, so maybe someone else has a better solution..

  3. #3
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: select range between letters

    Quote Originally Posted by Zeb
    2. try using a wildcard. i.e. WHERE itemno >= 'ab*'
    (I can't remember if wildcard is * or % in SQL Server)
    The wildcard is %

  4. #4
    Join Date
    Dec 2002
    Location
    Jordan
    Posts
    30

    Re: select range between letters

    hay all
    i will give example for data
    values
    1
    2
    3
    4
    10
    11
    12
    ap-512
    acd-42f
    sfv2-s
    a9-632

    .
    .
    etc
    suppose i want only records from 10 to a9-632
    it must give
    10,11,12,a9-632 only
    all fields is nvarchar type

    i try using sum ascii of value and save its value in field and when i want retrive any data i use sum ascii for number like
    12 ascii = 49+48=99 and so on
    but the problem that ascii sum value of 12 is same 21 and that not solve the problem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured