Results 1 to 14 of 14
  1. #1
    Join Date
    Sep 2007
    Posts
    3

    Unanswered: Validating Inputs and Finding Patterns with PatIndex

    ---Checks that input only contains numbers
    if PatIndex('%[^0-9]%','11') > 0
    Begin
    Print 'Not all numbers'
    End
    Else
    Begin
    Print 'All numbers'
    End

    ---Checks that input only contains letters
    if PatIndex('%[^a-z]%','aaaaa') > 0
    Begin
    Print 'Not all letters'
    End
    Else
    Begin
    Print 'All letters'
    End


    --Checking for mixed input
    If PatIndex('%[^0-9][0-9]%','abc') > 0
    Begin
    Print 'Alpha numeric data'
    End
    Else
    Begin
    Print 'Either all numbers or all letters'
    End

    --Checks that value must start with a letter and a number
    If PatIndex('[^0-9][0-9]%','A1anamwar11') > 0
    Begin
    Print 'Starts with a letter and a number'
    End
    Else
    Begin
    Print 'Does not start with a letter and a number'
    End

    --Checks that value must End with a letter and a number
    If PatIndex('%[^0-9][0-9]','A1anamwar11a1') > 0
    Begin
    Print 'Ends with a letter and a number'
    End
    Else
    Begin
    Print 'Does not End with a letter and a number'
    End


    --Checks that value must Start with a letter and Ends with a number
    If PatIndex('[^0-9]%[0-9]','namwar1') > 0
    Begin
    Print 'Starts with a letter and ends with a number'
    End
    Else
    Begin
    Print 'Does not start with a letter and ends with a number'
    End

    Namwar
    <Link removed by georgev>
    Last edited by gvee; 09-06-07 at 04:35.

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Did you have a legitimate question, or are you merely reposting well-known information that anyone can look up in a shameless attempt to promote your blog?

    You want to showcase your talents? There are plenty of questions on the forum you can help answer.

    You want to push traffic to your site? You will find yourself banned and your links removed.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Did you know you can't remove links in a sig...I tried

    And I think that was a wee bit harsh
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  4. #4
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    He has three posts. Have any of them been useful?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  5. #5
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    i like it when the b-man gets harsh. it puts my own personality disorder in perspective. ban the troll.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  6. #6
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by Thrasymachus
    ban the troll.
    You can't ban mods - I know because I tried.

    Oh wait - you meant the OP didn't you?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  7. #7
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Who asked you for your opinion, jackass?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  8. #8
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    with the winky, all is forgiven. even the truth.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  9. #9
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Certified Winkified.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  10. #10
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Wait!

    There's a donkey in the room?
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  11. #11
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    This has to be one of the funniest threads I've read in a long time
    George
    Home | Blog

  12. #12
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Really? I didn't think it was some of my best work, but thanks.
    Have you read the screenplay Mike and I are collaborating on?
    http://www.dbforums.com/showthread.p...93#post6294793
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  13. #13
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Is that a new sig?
    I only just noticed it and it made me chuckle
    George
    Home | Blog

  14. #14
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    that cursor thread is not comedy, it's tragedy. someone should ask mike how you send emails to 10,000 people without a loop of some kind. running totals, line numbering etc..., but I do not even want to get involved. i just hope i never have to rewrite one of his applications.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

Posting Permissions

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