Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8812325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:34:46+00:00 2026-06-14T03:34:46+00:00

I have this question for you.I am working a function which has the whole

  • 0

I have this question for you.I am working a function which has the whole address in one field.I am trying to separate it.I have started working on the one below and I am having difficulty when I try to work on the zip ,I want to test if there is a zip first at the end and if so I am trying to separate it from the state.Could you please have alook at it?Thanks alot guys as usual I appreciate you support..

      declare @var1 varchar(100)='1234 S.Almeda way,Seattle,WA9810'--just an example
        ,@u int
        ,@r int
        ,@var2 varchar(100)
        ,@var3 varchar(100)
        ,@Zip varchar(25)
        ,@var4 varchar(100)=null
             set @u = charindex(',', @var1)
             set @var2=rtrim(ltrim(substring(@var1, @u+1, 999)))
             set @r=CHARINDEX(',',@var2)
             set @var3=rtrim(ltrim(substring(@var2, @r+1, 999)))

             --set @var4=RIGHT(@var3,5)--not enough
             if (len(@var3)>=5 and ISNUMERIC(@var3)=1 )
             set  @var4=RIGHT(@var3,5)
             set rtrim(substring(@var3,1,len(@var3)-5))
             else set @var4=''
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T03:34:48+00:00Added an answer on June 14, 2026 at 3:34 am

    Here’s some sample code you can merge into yours

    declare @var1 varchar(100)='1234 S.Almeda way,Seattle,WA9810'--just an example
    declare @lastcomma int = len(@var1) - charindex(',', reverse(@var1)+',')
    declare @lastPart varchar(100) = substring(@var1, @lastcomma+2, 100)
    select @lastPart 
    declare @zipstart int = patindex('%[0-9]%', @lastpart)
    declare @zip varchar(5) = ''
    if @zipstart > 0
        select @zip = substring(@lastpart, @zipstart, 5), @lastPart = rtrim(substring(@lastpart,1,@zipstart-1))
    select @lastpart, @zip
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question has been edited: I am working with QML. I have a custom
Have been working on this question for a couple hours and have come close
I suppose this question is more general than working with COM components. I have
I have this question in which I have a SQL Server Compact Edition database
hello i have this question i was trying to find a way to call
I have a Telerik's RadGrid which has 2 columns like this: <Columns> <telerik:GridBoundColumn HeaderText=AirlineCode
Background I have a project named PersonLibrary which has two files. Person.h Person.cpp This
I have this question, just in theory. I do some query results and there
I have this question because I am not familiar latest generation of MS VS
I have this question: How could I call a codebehind method from jquery? I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.