Click here to Skip to main content
16,008,954 members
Home / Discussions / Database
   

Database

 
QuestionSSIS Variable Problem Pin
Vimalsoft(Pty) Ltd3-Nov-09 2:20
professionalVimalsoft(Pty) Ltd3-Nov-09 2:20 
QuestionHow can we Empty the whole tables by one single query Pin
lrsalunkhe3-Nov-09 2:09
lrsalunkhe3-Nov-09 2:09 
AnswerRe: How can we Empty the whole tables by one single query Pin
Niladri_Biswas3-Nov-09 2:50
Niladri_Biswas3-Nov-09 2:50 
AnswerRe: How can we Empty the whole tables by one single query Pin
David Mujica3-Nov-09 3:40
David Mujica3-Nov-09 3:40 
GeneralRe: How can we Empty the whole tables by one single query Pin
lrsalunkhe3-Nov-09 17:20
lrsalunkhe3-Nov-09 17:20 
GeneralRe: How can we Empty the whole tables by one single query Pin
_Damian S_3-Nov-09 18:02
professional_Damian S_3-Nov-09 18:02 
GeneralRe: How can we Empty the whole tables by one single query [modified] Pin
Niladri_Biswas3-Nov-09 18:39
Niladri_Biswas3-Nov-09 18:39 
GeneralRe: How can we Empty the whole tables by one single query Pin
Mycroft Holmes3-Nov-09 19:03
professionalMycroft Holmes3-Nov-09 19:03 
GeneralRe: How can we Empty the whole tables by one single query Pin
_Damian S_3-Nov-09 19:09
professional_Damian S_3-Nov-09 19:09 
GeneralRe: How can we Empty the whole tables by one single query Pin
Mycroft Holmes3-Nov-09 19:13
professionalMycroft Holmes3-Nov-09 19:13 
GeneralRe: How can we Empty the whole tables by one single query Pin
_Damian S_3-Nov-09 19:23
professional_Damian S_3-Nov-09 19:23 
GeneralRe: How can we Empty the whole tables by one single query Pin
J4amieC3-Nov-09 23:52
J4amieC3-Nov-09 23:52 
GeneralRe: How can we Empty the whole tables by one single query Pin
Ashfield4-Nov-09 7:31
Ashfield4-Nov-09 7:31 
QuestionSSRS - web service interface generated pdf's with slightly different font/color Pin
devvvy3-Nov-09 0:46
devvvy3-Nov-09 0:46 
QuestionTable could not found Pin
haleemasher2-Nov-09 22:33
haleemasher2-Nov-09 22:33 
AnswerRe: Table could not found Pin
Niladri_Biswas2-Nov-09 23:55
Niladri_Biswas2-Nov-09 23:55 
Questionneed latest records Pin
Member 38798812-Nov-09 18:23
Member 38798812-Nov-09 18:23 
AnswerRe: need latest records Pin
Niladri_Biswas2-Nov-09 19:34
Niladri_Biswas2-Nov-09 19:34 
Try this

declare @tblMaster table(pid int primary key,name varchar(20))
insert into @tblMaster
select 1,'m1' union all select 2,'m2' union all
select 3,'m3' union all select 4,'m4' union all
select 5,'m5' union all select 6,'m6'

declare @tblChild table(cid int primary key,pid int,name varchar(20))
insert into @tblChild
select 1,2,'nm1' union all select 2,2,'nm2' union all
select 3,1,'nm3' union all select 4,5,'nm4' union all
select 5,6,'nm5'

select pid,cid,name from
(
select 
	m.pid
	,c.cid
	,case when c.name IS null then m.name
		else c.name 
	end name
	,row_number() over(partition by m.pid order by c.name desc) as rn 

from @tblChild c
full join @tblMaster m
on  c.pid = m.pid
)x(pid,cid,name,rn)
where rn = 1
order by  pid desc

Smile | :)

Niladri Biswas

GeneralRe: need latest records Pin
Member 38798812-Nov-09 19:49
Member 38798812-Nov-09 19:49 
GeneralRe: need latest records Pin
Niladri_Biswas2-Nov-09 20:11
Niladri_Biswas2-Nov-09 20:11 
AnswerRe: need latest records Pin
Ashfield2-Nov-09 21:10
Ashfield2-Nov-09 21:10 
QuestionNOT EXISTS function not working Pin
Bomb_shell2-Nov-09 11:54
Bomb_shell2-Nov-09 11:54 
AnswerRe: NOT EXISTS function not working Pin
Mycroft Holmes2-Nov-09 13:59
professionalMycroft Holmes2-Nov-09 13:59 
GeneralRe: NOT EXISTS function not working Pin
Bomb_shell3-Nov-09 10:47
Bomb_shell3-Nov-09 10:47 
AnswerRe: NOT EXISTS function not working Pin
Niladri_Biswas2-Nov-09 16:46
Niladri_Biswas2-Nov-09 16:46 

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.