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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:25:27+00:00 2026-05-20T00:25:27+00:00

I have a table data as col1 col2 col3 col4 11 12 xx yy

  • 0

I have a table data as

col1    col2    col3   col4
11       12     xx yy    20
22       13     qq aa    21

my TDD requried using TSQL as

col1     col2    col3    col4
11       12       xx      20
11       12       yy      20
22       13       qq      21
22       13       aa      21

basically, col3 is having values with space, need to create the rows for each value separed by space value.

thanks
prav

  • 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-20T00:25:27+00:00Added an answer on May 20, 2026 at 12:25 am

    Have a look at something like this

    DECLARE @Table TABLE(
            col1 INT,
            col2 INT,
            col3 VARCHAR(50),
            col4 INT
    )
    
    INSERT INTO @Table SELECT  11,12,'xx yy',20  
    INSERT INTO @Table SELECT  22,13,'qq aa',21
    
    ;WITH Vals AS (
        SELECT  *,
                CAST('<d>' + REPLACE(col3, ' ', '</d><d>') + '</d>' AS XML) XMLCol
        FROM    @Table
    )
    SELECT  Vals.*,
            T.split.value('.', 'VARCHAR(MAX)') SplitValue
    FROM    Vals
    CROSS APPLY
            XMLCol.nodes('/d') T(split)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using SQL SERVER 2005. I have a table table1(ID,col1,col2,col3,col4); Now I have
I have a table like this Table1 Col1 Col2 Col3 Col4 Col5 Col6 Col7
I have a table that looks like this: Col1 Col2 Col3 Col4 a b
Situation is as below. I have a table like here: Col1 Col2 Col3 Col4
I have table, MyTable, in Oracle 11GR2: COL1 VARCHAR2 COL2 VARCHAR2 COL3 VARCHAR2 COL4
Lets say i have a table like this: col1 col2 col3 row1 1 null
I have a table finance (column : date,month,quarter,amount_usd,col1,col2,col3). Simply querying ... select sum(amount_usd) from
Table: CREATE TABLE Table1 ( col1 INT, col2 nvarchar(10), col3 INT, col4 INT );
So i have a query that looks like this: SELECT col1, col2, col3 ...
My source CSV is comma delimited. Example Col1, Col2, Col3 Destinatin SQL Table Col1,

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.