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 2005 Forums
 Transact-SQL (2005)
 Concatenate query results

Author  Topic 

Mondeo
Constraint Violating Yak Guru

287 Posts

Posted - 2008-01-25 : 06:33:02
Hi,

I've got 3 queries which all return a single value. I'm trying to join these 3 values to return just 1.

I've tried this

SELECT * FROM (
(SELECT TOP 1 [text] from tblRandomText WHERE section = 1 ORDER BY NEWID()) &
(SELECT TOP 1 [text] from tblRandomText WHERE section = 2 ORDER BY NEWID()) &
(SELECT TOP 1 [text] from tblRandomText WHERE section = 3 ORDER BY NEWID()) &
)

But it doesn't work.

Is there any way to do this?

Thanks

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-01-25 : 07:58:16
SELECT (SELECT TOP 1 [text] from tblRandomText WHERE section = 1 ORDER BY NEWID()) +
(SELECT TOP 1 [text] from tblRandomText WHERE section = 2 ORDER BY NEWID()) +
(SELECT TOP 1 [text] from tblRandomText WHERE section = 3 ORDER BY NEWID())


_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com <- new version out
Go to Top of Page
   

- Advertisement -