Click here to Skip to main content
15,922,155 members
Home / Discussions / Database
   

Database

 
AnswerRe: SQL Server 2005 - Passing 2 Dim. Array to SP Pin
Niladri_Biswas5-Nov-09 16:56
Niladri_Biswas5-Nov-09 16:56 
QuestionSQL Server 2005 - Working with IDENTITY column Pin
Anusha.19805-Nov-09 7:04
Anusha.19805-Nov-09 7:04 
AnswerRe: SQL Server 2005 - Working with IDENTITY column Pin
Mycroft Holmes5-Nov-09 14:20
professionalMycroft Holmes5-Nov-09 14:20 
AnswerRe: SQL Server 2005 - Working with IDENTITY column Pin
Niladri_Biswas5-Nov-09 17:22
Niladri_Biswas5-Nov-09 17:22 
AnswerRe: SQL Server 2005 - Working with IDENTITY column Pin
Shameel9-Nov-09 3:08
professionalShameel9-Nov-09 3:08 
QuestionMS SQL Selecting all rows in one table and only rows matching in a second Pin
Steven J Jowett5-Nov-09 2:48
Steven J Jowett5-Nov-09 2:48 
AnswerRe: MS SQL Selecting all rows in one table and only rows matching in a second Pin
J4amieC5-Nov-09 3:05
J4amieC5-Nov-09 3:05 
AnswerRe: MS SQL Selecting all rows in one table and only rows matching in a second Pin
Niladri_Biswas5-Nov-09 3:41
Niladri_Biswas5-Nov-09 3:41 
Hi,
But I have used your code only and is getting the correct result.

declare @tblProduct table(Productid int )
insert into @tblProduct select 1 union all select 2 union all select 3 union all
select 4 union all select 5


declare @tblReceipts table(Receiptid int,Productid int,Quantity decimal )
insert into @tblReceipts
select 1,1,20 union all
select 1,1,30 union all
select 2,1,40 union all
select 2,1,12 union all
select 3,1,45 union all
select 2,2,45 union all
select 1,1,20 union all
select 1,1,30 union all
select 2,1,40 union all
select 2,1,12 union all
select 2,1,45 union all
select 2,2,45

select ProductId,ReceiptId,Quantity from
(SELECT TOP (100) PERCENT p.ProductId, r.ReceiptId, r.Quantity
FROM         @tblProduct p LEFT JOIN
             @tblReceipts r 
ON p.ProductId = r.ProductId ) X(ProductId,ReceiptId,Quantity)
where   X.ReceiptId = 2 OR X.ReceiptId is NULL


The output is as desired:

ProductId	ReceiptId	Quantity
1	2	40
1	2	12
1	2	40
1	2	12
1	2	45
2	2	45
2	2	45
3	NULL	NULL
4	NULL	NULL
5	NULL	NULL


So what is ur doubt? Can u give us some datapoints so that we can give a better insight!
Smile | :)

Niladri Biswas

AnswerRe: MS SQL Selecting all rows in one table and only rows matching in a second Pin
David Skelly5-Nov-09 5:27
David Skelly5-Nov-09 5:27 
GeneralRe: MS SQL Selecting all rows in one table and only rows matching in a second Pin
Steven J Jowett5-Nov-09 6:57
Steven J Jowett5-Nov-09 6:57 
GeneralRe: MS SQL Selecting all rows in one table and only rows matching in a second Pin
David Skelly5-Nov-09 23:08
David Skelly5-Nov-09 23:08 
GeneralRe: MS SQL Selecting all rows in one table and only rows matching in a second Pin
Steven J Jowett5-Nov-09 23:36
Steven J Jowett5-Nov-09 23:36 
QuestionUsing OPENROWSET Pin
si_695-Nov-09 2:08
si_695-Nov-09 2:08 
AnswerRe: Using OPENROWSET Pin
jacob.sebastian6-Nov-09 9:38
jacob.sebastian6-Nov-09 9:38 
QuestionHelp On Read Image column from MS Acess Database Pin
maysam gamini5-Nov-09 0:55
maysam gamini5-Nov-09 0:55 
QuestionSql Server 2008 Installing Issue-Not able to see the "Feature Selection " window and further windows after installing till supporting Files Pin
srikrishnakrishna murthy4-Nov-09 23:27
srikrishnakrishna murthy4-Nov-09 23:27 
QuestionHow to assign a query result to a stored procedure Pin
Nekkantidivya4-Nov-09 23:14
Nekkantidivya4-Nov-09 23:14 
AnswerRe: How to assign a query result to a stored procedure Pin
Eddy Vluggen5-Nov-09 0:08
professionalEddy Vluggen5-Nov-09 0:08 
AnswerRe: How to assign a query result to a stored procedure Pin
Syed Mehroz Alam5-Nov-09 0:45
Syed Mehroz Alam5-Nov-09 0:45 
AnswerRe: How to assign a query result to a stored procedure Pin
Niladri_Biswas5-Nov-09 3:19
Niladri_Biswas5-Nov-09 3:19 
QuestionWhat is the diffrence between SQL Express and SQL Managment Studio ? Pin
nileshbahirshet4-Nov-09 20:57
nileshbahirshet4-Nov-09 20:57 
AnswerRe: What is the diffrence between SQL Express and SQL Managment Studio ? Pin
Mycroft Holmes4-Nov-09 21:09
professionalMycroft Holmes4-Nov-09 21:09 
AnswerRe: What is the diffrence between SQL Express and SQL Managment Studio ? Pin
Niladri_Biswas4-Nov-09 21:28
Niladri_Biswas4-Nov-09 21:28 
AnswerRe: What is the diffrence between SQL Express and SQL Managment Studio ? Pin
Eddy Vluggen4-Nov-09 23:03
professionalEddy Vluggen4-Nov-09 23:03 
Questionsql v/s ms access Pin
sachees1234-Nov-09 20:29
sachees1234-Nov-09 20:29 

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.