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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:43:25+00:00 2026-05-31T11:43:25+00:00

I have been a curious , whether is this possible in SQL Here is

  • 0

I have been a curious , whether is this possible in SQL

Here is my table

Text
-----
India 01/01/2001 Mumbai
SriLanka 01/01/2001 Colombo
USA 01/01/2001 Chicago

From these create table separate columns (separated by space) like

Country     Date        Location  
-----       -----       -------- 
India       01/01/2001   Mumbai
SriLanka    01/01/2001   Colombo
USA         01/01/2001   Chicago

Only thing that structs me over here is regex that we do in JAVA.

Is something like possible in SQL as well.

Thanks !!!

  • 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-31T11:43:27+00:00Added an answer on May 31, 2026 at 11:43 am

    You could split the columns with a table-valued function like this:

    CREATE FUNCTION [dbo].[fnParseFields] ( @str NVARCHAR(max), @delimiter NCHAR )
    RETURNS @retval TABLE(Country NVARCHAR(max), [Date] NVARCHAR(max), Location NVARCHAR(max))
    AS
    BEGIN
        declare @f1 varchar(max), @f2 varchar(max), @f3 varchar(max);
        set @str=ltrim(@str);
    
        -- Field 1
        set @f1=(left(@str,CHARINDEX(@delimiter,@str,1)-1));
        SET @str=RIGHT(@str,LEN(@str)-CHARINDEX(@delimiter,@str,1));
    
        -- Field 2
        set @f2=(left(@str,CHARINDEX(@delimiter,@str,1)-1));
    
        -- Field 3
        SET @f3=RIGHT(@str,LEN(@str)-CHARINDEX(@delimiter,@str,1));
        insert into @retval values (@f1,@f2,@f3);
    
        RETURN;
    END
    
    GO
    
    create table myText (sometext varchar(80));
    
    insert into myText values
    ('India 01/01/2001 Mumbai')
    , ('SriLanka 01/01/2001 Colombo')
    , ('USA 01/01/2001 Chicago');
    go
    
    select f.* from myText
    cross apply [dbo].[fnParseFields](sometext,' ') f
    go
    

    Result:

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ever since I started programming this has been something I have been curious about.
I come across this a lot, and have always been curious if there is
I have always been curious about this - why do in C++ I have
I have been looking around here and There , and I have become curious.
I have been curious to know what is the purpose of having a console
I have been curious about dynamically create class at runtime in C# and stumbled
I have been reading through the C++ FAQ and was curious about the friend
I have been using IoC for a little while now and I am curious
I have been a .net developer for the past three yrs. Just curious to
I have been curious as to which method of CSS styling is quicker (rendering

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.