append data into t-sql cursor

Posted on 2008-11-17
Last Modified: 2012-05-05
i wanted select * from table1 where id=1 to retrieve the data two times - ie the single row should get duplicated and appended below the result returned from above query.
eg. select a,b,c from table1where id-1 should return data like below
a                        b                   c
xys                    abc               def
xys                    abc               def
can someone help?
thanks in advance
Question by:vinodand
    LVL 9

    Expert Comment

    Try this:
    select * from table1 where id=1
    union all
    select * from table1 where id=1

    Open in new window

    LVL 26

    Accepted Solution

    try this

    select * from table1, (select 1 a union select 2 a) b
    where id = 1
    order by id
    LVL 68

    Assisted Solution

    SELECT table1.*
    FROM table1
        SELECT 1 AS #timesToDuplicate UNION ALL
        SELECT 2
    ) AS forceDuplicateRowsInOutput
    WHERE = 1

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Performance is the key factor for any successful data integration project, knowing the type of transformation that you’re using is the first step on optimizing the SSIS flow performance, by utilizing the correct transformation or the design alternat…
    Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
    This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
    Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now