Click here to Skip to main content
15,890,527 members
Home / Discussions / Database
   

Database

 
AnswerRe: Difference between sql server 2000 and 2005 Pin
Pete O'Hanlon2-Jul-07 9:40
mvePete O'Hanlon2-Jul-07 9:40 
AnswerRe: Difference between sql server 2000 and 2005 Pin
leckey2-Jul-07 11:45
leckey2-Jul-07 11:45 
QuestionSubquery returned more than 1 value Pin
Sam Heller2-Jul-07 5:47
Sam Heller2-Jul-07 5:47 
AnswerRe: Subquery returned more than 1 value Pin
jonathan152-Jul-07 6:56
jonathan152-Jul-07 6:56 
GeneralRe: Subquery returned more than 1 value Pin
Sam Heller2-Jul-07 7:00
Sam Heller2-Jul-07 7:00 
GeneralRe: Subquery returned more than 1 value Pin
jonathan152-Jul-07 7:09
jonathan152-Jul-07 7:09 
GeneralRe: Subquery returned more than 1 value Pin
Sam Heller2-Jul-07 9:53
Sam Heller2-Jul-07 9:53 
AnswerRe: Subquery returned more than 1 value [modified] Pin
Harini N K3-Jul-07 0:58
Harini N K3-Jul-07 0:58 
Hi
You can write your sub-query in a separate function. (table-valued function). Using this function, you can join with the main query as given below.

Select Col1, Col2, dbo.Fn_SubQuery(param1,param2)
from Table1

Hope this helps.

See the example below


<br />
use northwind<br />
go<br />
create function dbo.Fn_OrdersProductID(@OrderID int)<br />
returns nvarchar(4000)<br />
as <br />
begin<br />
DECLARE @ProductID nvarchar(4000)<br />
set @ProductID = null <br />
SELECT @ProductID = COALESCE(@ProductID + ',','') + cast(ProductID as nvarchar)<br />
FROM [Order Details]<br />
WHERE OrderID = @OrderID<br />
<br />
RETURN @ProductID<br />
<br />
end<br />
<br />
-- run the foll. stmt after executing the above function<br />
-- SELECT OrderID,dbo.Fn_OrdersProductID(OrderID) from Orders


Apply the same for your query

-- modified at 7:08 Tuesday 3rd July, 2007


-- modified at 7:11 Tuesday 3rd July, 2007

Harini

GeneralRe: Subquery returned more than 1 value Pin
Praveen02928-Aug-07 0:29
Praveen02928-Aug-07 0:29 
AnswerRe: Subquery returned more than 1 value Pin
DQNOK3-Jul-07 5:05
professionalDQNOK3-Jul-07 5:05 
Questionsecure DB Pin
merwa2-Jul-07 0:21
merwa2-Jul-07 0:21 
AnswerRe: secure DB Pin
leckey2-Jul-07 11:48
leckey2-Jul-07 11:48 
AnswerRe: secure DB Pin
Mike Dimmick2-Jul-07 12:28
Mike Dimmick2-Jul-07 12:28 
QuestionMSAccess Pin
nitin32-Jul-07 0:19
nitin32-Jul-07 0:19 
AnswerRe: MSAccess Pin
martin_hughes2-Jul-07 0:29
martin_hughes2-Jul-07 0:29 
GeneralRe: MSAccess Pin
nitin32-Jul-07 0:37
nitin32-Jul-07 0:37 
AnswerRe: MSAccess Pin
Rahul.Goel2-Jul-07 21:41
Rahul.Goel2-Jul-07 21:41 
QuestionTime Out Error Pin
sajmera2-Jul-07 0:11
sajmera2-Jul-07 0:11 
AnswerRe: Time Out Error Pin
kubben2-Jul-07 2:18
kubben2-Jul-07 2:18 
Questiondisplay 2 table records in a single asp page Pin
dheema2-Jul-07 0:02
dheema2-Jul-07 0:02 
AnswerRe: display 2 table records in a single asp page Pin
gauthee10-Jul-07 21:52
gauthee10-Jul-07 21:52 
QuestionWant to add column in table in dynamic query Pin
Khawar Abbas12-Jul-07 0:01
Khawar Abbas12-Jul-07 0:01 
AnswerRe: Want to add column in table in dynamic query Pin
andyharman2-Jul-07 0:31
professionalandyharman2-Jul-07 0:31 
QuestionReading/Writing text files in Oracle Pin
Mangilipelli1-Jul-07 23:32
Mangilipelli1-Jul-07 23:32 
AnswerRe: Reading/Writing text files in Oracle Pin
andyharman2-Jul-07 0:30
professionalandyharman2-Jul-07 0:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.