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 6946543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:34:42+00:00 2026-05-27T13:34:42+00:00

I have string column email_id ; the data will look like this: email_id 1

  • 0

I have string column email_id; the data will look like this:

email_id 
"1"
"6"
"3 4"
"8"
"0 3"
"0 5 7"

I want to get list of ids as integer. If I have two numbers in my string, I want the last one. My result should look like;

SELECT some_function (email_id ) FROM table
1
6
4
8
3
7

Is it possible to do this in SQL Server?

  • 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-05-27T13:34:43+00:00Added an answer on May 27, 2026 at 1:34 pm
    SELECT
      CAST(RIGHT(email_id, LEN(email_id) - CHARINDEX(' ', email_id)) AS INT)
    FROM
      yourTable
    

    IF and ONLY IF, all your values can reliably be cast to an INT, and there is only ever one space at most.

    EDIT To deal with a list of n values

    This isn’t pretty, but it avoid recurrsion and/or loops. If someone gives an answer without REVERSE() test to see if it’s faster than this or not.

    SELECT
      CAST(
        REVERSE(
          LEFT(
            REVERSE(email_id),
            CHARINDEX(' ', REVERSE(email_id) + ' ') - 1
          )
        )
        AS INT
      )
    FROM
      yourTable
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have column that contains strings. The strings in that column look like this:
I have a label function like : private function formatDate (item:Object, column:DataGridColumn):String { var
I have a column of data that contains a percentage range as a string
I have string column with numbers in a datagridview.It is not bound, I would
I have a string column in a database table which maps to an Enum
I have mysql table that has a column that stores xml as a string.
I have a DataTable object. Every column is of type string. Using LINQ, how
I have a Datatable with Id(guid) and Name(string) columns. I traverse through the data
I have a domain object annotated like this for hibernate support. @Entity @Table(name =
I have a GridView just like this: <asp:GridView ID=gvwStudents runat=server AutoGenerateColumns=False DataKeyNames=ID ShowHeader=False onrowdeleting=gvwStudents_RowDeleting>

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.