1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Select Mid() in MS SQL Server 7

Discussion in 'Business Applications' started by savagej21, Nov 14, 2001.

Thread Status:
Not open for further replies.
Advertisement
  1. savagej21

    savagej21 Thread Starter

    Joined:
    Nov 14, 2001
    Messages:
    4
    I am trying to use the select mid command in SQL Server 7, only to learn that it's not supported--Does anyone know how to do this? Here's what I'm trying to do.

    I want to break a 10-digit phone number into area code, prefix, and last four digits. In Oracle SQL I would type:

    select left(PhoneNumber,3) as 'AreaCode, mid(PhoneNumber,4,3) as 'Prefix', right(PhoneNumber,4) as 'Last4Digits'.

    However when I try to do this in SQL Server Query Analyzer, I receive a notice that 'mid' is not a function.

    Help! :) Thanks in advance.:confused:
     
  2. Rockn

    Rockn

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    Try Mid$
     
  3. savagej21

    savagej21 Thread Starter

    Joined:
    Nov 14, 2001
    Messages:
    4
    That didn't work either. :-/
     
  4. downwitchyobadself

    downwitchyobadself

    Joined:
    Oct 13, 2000
    Messages:
    941
    You might play with this. Note that it's pulling bytes, so look out for unicode.

    If you are in fact working with binary data, you should read this bug report, too, though it does not mention mid--does mention the other string functions, tho. Have you searched SQL Server help for string functions?
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/58576

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice