Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 309
  • Last Modified:

append data into t-sql cursor

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
0
vinodand
Asked:
vinodand
2 Solutions
 
amxCommented:
Try this:
select * from table1 where id=1
union all
select * from table1 where id=1

Open in new window

0
 
tigin44Commented:
try this

select * from table1, (select 1 a union select 2 a) b
where id = 1
order by id
0
 
Scott PletcherSenior DBACommented:
SELECT table1.*
FROM table1
CROSS JOIN (
    SELECT 1 AS #timesToDuplicate UNION ALL
    SELECT 2
) AS forceDuplicateRowsInOutput
WHERE table1.id = 1
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now