Click here to Skip to main content
15,912,756 members
Home / Discussions / Database
   

Database

 
QuestionService Account Pin
Satish Pai1-Jun-09 18:50
Satish Pai1-Jun-09 18:50 
AnswerRe: Service Account Pin
Niladri_Biswas7-Jun-09 0:12
Niladri_Biswas7-Jun-09 0:12 
QuestionWhere to store my files? Pin
musefan1-Jun-09 4:04
musefan1-Jun-09 4:04 
AnswerRe: Where to store my files? Pin
David Mujica1-Jun-09 4:28
David Mujica1-Jun-09 4:28 
GeneralRe: Where to store my files? Pin
musefan1-Jun-09 4:36
musefan1-Jun-09 4:36 
GeneralGo with storing files on fileserver Pin
David Mujica1-Jun-09 5:29
David Mujica1-Jun-09 5:29 
GeneralRe: Go with storing files on fileserver Pin
musefan1-Jun-09 5:46
musefan1-Jun-09 5:46 
AnswerRe: Where to store my files? Pin
Eddy Vluggen1-Jun-09 5:05
professionalEddy Vluggen1-Jun-09 5:05 
GeneralRe: Where to store my files? Pin
musefan1-Jun-09 5:13
musefan1-Jun-09 5:13 
GeneralRe: Where to store my files? Pin
Eddy Vluggen1-Jun-09 7:57
professionalEddy Vluggen1-Jun-09 7:57 
QuestionVFP OLE DB Provider error: Variable X is not found Pin
dasha_pl1-Jun-09 3:35
dasha_pl1-Jun-09 3:35 
QuestionSQL 2008 Workgroup - how do CALs work? Pin
aastudent1-Jun-09 0:38
aastudent1-Jun-09 0:38 
AnswerRe: SQL 2008 Workgroup - how do CALs work? Pin
Mycroft Holmes1-Jun-09 1:14
professionalMycroft Holmes1-Jun-09 1:14 
GeneralRe: SQL 2008 Workgroup - how do CALs work? Pin
aastudent1-Jun-09 1:26
aastudent1-Jun-09 1:26 
Questionproblem in executing stored procedure Pin
souravghosh1831-May-09 20:12
souravghosh1831-May-09 20:12 
AnswerRe: problem in executing stored procedure Pin
Aman Bhullar6-Jun-09 1:50
Aman Bhullar6-Jun-09 1:50 
AnswerRe: problem in executing stored procedure Pin
Niladri_Biswas25-Jun-09 5:57
Niladri_Biswas25-Jun-09 5:57 
QuestionCONTAINS not working in my full text search Pin
Brendan Vogt31-May-09 5:13
Brendan Vogt31-May-09 5:13 
AnswerRe: CONTAINS not working in my full text search Pin
Satish Pai31-May-09 19:49
Satish Pai31-May-09 19:49 
Questionline break not working in crystal reports ? Pin
kindman_nb30-May-09 21:58
kindman_nb30-May-09 21:58 
AnswerRe: line break not working in crystal reports ? Pin
Rajesh Anuhya1-Jun-09 0:03
professionalRajesh Anuhya1-Jun-09 0:03 
QuestionHelp with SQL query Pin
Joe_P30-May-09 10:30
Joe_P30-May-09 10:30 
declare @BatchHeader table
(bhid int, status int)
insert into @BatchHeader values (1, 10)
insert into @BatchHeader values (2, 10)
insert into @BatchHeader values (3, 10)
insert into @BatchHeader values (4, 10)
insert into @BatchHeader values (5, 15)
insert into @BatchHeader values (6, 15)
insert into @BatchHeader values (7, 15)

select * from @BatchHeader

declare @BatchHeaderReference table
(parentid int, child int)

insert into @BatchHeaderReference values (1,2)
insert into @BatchHeaderReference values (1,3)
insert into @BatchHeaderReference values (1,4)
insert into @BatchHeaderReference values (1,5)
insert into @BatchHeaderReference values (1,6)
insert into @BatchHeaderReference values (1,7)

select * from @BatchHeaderReference

@BatchHeaderReference.ParentId and Child are the FKs to @BatchHeader.bhid

The output is this:
@BatchHeader
bhid Status
1 10
2 10
3 10
4 10
5 15
6 15
7 15

@BatchHeaderReference
Parentid Child
1 2
1 3
1 4
1 5
1 6
1 7

I want to write a query to fetch unique @BatchHeader rows only if the parent and child have status = 10. So in this case the query shoudnt return any @BatchHeader rows (bcos bhid 5,6,7 have status 15). But if I update the status for bhid=5,6,7 to 10 then the query should return bhid=1.

I tried something like this but it returns bhid=1
Select Distinct bhr.ParentId From @BatchHeaderReference bhr
Join @BatchHeader bh1 with (readpast) on bhr.Child = bh1.bhid
Join @BatchHeader bh2 with (readpast) on bhr.ParentId = bh2.bhid
Where
bh1.Status = 10 -- Child batch status
And bh2.Status = 10 -- Header batch status


Please help.

Thanks,
Joe
AnswerRe: Help with SQL query Pin
Mycroft Holmes30-May-09 23:06
professionalMycroft Holmes30-May-09 23:06 
GeneralRe: Help with SQL query Pin
Joe_P31-May-09 4:11
Joe_P31-May-09 4:11 
GeneralRe: Help with SQL query Pin
Mycroft Holmes31-May-09 11:10
professionalMycroft Holmes31-May-09 11:10 

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.