Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 extra row in resultset

Author  Topic 

xpandre
Posting Yak Master

212 Posts

Posted - 2002-08-12 : 09:57:47
Hi,
How do i add an extra row...a dummy in my result set?

thanx
Sam

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-08-12 : 10:04:13
UNION

select col1 from mytable
union
select 'dummy'

(col1 and 'dummy' must be of compatible types)

Jay White
{0}
Go to Top of Page

xpandre
Posting Yak Master

212 Posts

Posted - 2002-08-12 : 10:06:17
thanx!!
but 1 probs!!

its like this

select * from table1
union
select 'dummy','dummy','dummy' from table1

wat if i dont have the count of the no of cols returned..

thanx
Sam

Go to Top of Page

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-08-12 : 10:10:15
quote:

wat if i dont have the count of the no of cols returned..



Then you can't do it .

Reason Number 47 why 'SELECT *' is a poor construct for production queries.

Jay White
{0}
Go to Top of Page

xpandre
Posting Yak Master

212 Posts

Posted - 2002-08-12 : 10:20:20
:D

thanx!!!

Go to Top of Page

xpandre
Posting Yak Master

212 Posts

Posted - 2002-08-12 : 10:50:08
ne other ideas?

Go to Top of Page

Arnold Fribble
Yak-finder General

1961 Posts

Posted - 2002-08-12 : 11:21:36
If all your 'dummy' values are actually NULLs then it's possible... though why you would want to add a row of NULLs to your result is beyond me.

SELECT * FROM mytable
UNION ALL
SELECT mytable.* FROM (SELECT 1 AS A) AS A LEFT JOIN mytable ON 1 = 0

 



Go to Top of Page
   

- Advertisement -