Click here to Skip to main content
15,917,005 members
Home / Discussions / Database
   

Database

 
AnswerDivide and conquer Pin
David Mujica5-May-09 5:11
David Mujica5-May-09 5:11 
GeneralRe: Divide and conquer Pin
vasini5-May-09 7:53
vasini5-May-09 7:53 
GeneralRe: Divide and conquer Pin
David Mujica5-May-09 8:20
David Mujica5-May-09 8:20 
Questionsecurity in MS access Pin
hrishiS5-May-09 2:01
hrishiS5-May-09 2:01 
AnswerRe: security in MS access Pin
Eddy Vluggen5-May-09 7:26
professionalEddy Vluggen5-May-09 7:26 
GeneralRe: security in MS access Pin
hrishiS5-May-09 21:19
hrishiS5-May-09 21:19 
GeneralRe: security in MS access Pin
Eddy Vluggen6-May-09 2:13
professionalEddy Vluggen6-May-09 2:13 
QuestionDuplicates Helps Pin
Vimalsoft(Pty) Ltd4-May-09 21:42
professionalVimalsoft(Pty) Ltd4-May-09 21:42 
Good Morning All

i have the Following Results


DESCR                CYCLES                
---------------------------------------
Galloway A Ms         20 21  
Gama, E               20 21   
Giatsi M Ms           20 21   
Gibbon F Prof         20 21  
Gibson C Ms           20 21   
Gilfillin, P          20 21   
Galloway A Ms         21 20   
Gama, E               21 20  
Giatsi M Ms           21 20   
Gibbon F Prof         21 20   
Gibson C Ms           21 20   
Gilfillin, P          21 20 


Now all this are Correct but i need to get rid of a duplicates. Check the Bolded part

Gilfillin, P 21 20 . i have reproduced this table from the Following

I have a First Stored Procedure doing the Following

ALTER PROC [dbo].[sp_Get_Staff_Cycles]
(
@ACTIVITY_ID INT
)
AS
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[FINAL]'))
drop table [FINAL]

SELECT  S.DESCR,ISNULL(MTN.CYCLETEMPLATE,C.CYCLES) AS CYCLETEMPLATE
INTO FINAL FROM TBL_STAFF S
INNER JOIN MTM_ACTV_STAFF MTN ON
S.ID = MTN.STAFF
LEFT OUTER JOIN tbl_Cycles_Staff C
ON C.IDL = MTN.ID
WHERE MTN.ACTV = @ACTIVITY_ID


and lets Follow the Final table and the following Stored Procedure that does the Following

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

/*
This Sp is the one that Arrange the Cycles from the Grid, the way Paul requested it
if the Grid Has more than one description, append the cyle to another one and remove it
*/

ALTER  PROC [dbo].[sp_Get_Staff_Cycles_internal]

AS
--
 IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[FINAL_NEW_FINAL]')) 
 DROP TABLE FINAL_NEW_FINAL
--ADD THIS TO A NEW TABLE NAMED 'FINAL_NEW_FINAL'
Select t1.DESCR,  STR(t1.CYCLETEMPLATE) + ''+ STR(t2.CYCLETEMPLATE) AS [CYCLES]
INTO FINAL_NEW_FINAL From FINAL t1, FINAL t2
Where t2.DESCR = t1.DESCR
And t2.CYCLETEMPLATE <> t1.CYCLETEMPLATE;

--Get the Missing Records
--INSERT THE ONE THAT WAS MISSING 
INSERT INTO FINAL_NEW_FINAL
SELECT DESCR ,CYCLETEMPLATE 
FROM FINAL 
WHERE DESCR NOT IN (SELECT DESCR FROM FINAL_NEW_FINAL)

-- Final Data for Rendering
SELECT DESCR,CYCLES FROM  FINAL_NEW_FINAL


Now this above sp produce those Duplicates


Thank you

Vuyiswa Maseko,

Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."

C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/

AnswerRe: Duplicates Helps Pin
Tim Carmichael4-May-09 23:30
Tim Carmichael4-May-09 23:30 
GeneralRe: Duplicates Helps Pin
Vimalsoft(Pty) Ltd4-May-09 23:46
professionalVimalsoft(Pty) Ltd4-May-09 23:46 
GeneralRe: Duplicates Helps Pin
WoutL5-May-09 0:24
WoutL5-May-09 0:24 
GeneralRe: Duplicates Helps Pin
Vimalsoft(Pty) Ltd5-May-09 1:29
professionalVimalsoft(Pty) Ltd5-May-09 1:29 
QuestionFreeText in SQL Server 2005 Pin
NarVish4-May-09 19:51
NarVish4-May-09 19:51 
QuestionCURSOR visibility/scope (MySQL + Oracle + M$SQL) Pin
devvvy4-May-09 19:23
devvvy4-May-09 19:23 
AnswerRe: CURSOR visibility/scope (MySQL + Oracle + M$SQL) Pin
Mycroft Holmes5-May-09 15:01
professionalMycroft Holmes5-May-09 15:01 
Questionneed help with rowid values Pin
MeRoX4-May-09 9:17
MeRoX4-May-09 9:17 
AnswerRe: need help with rowid values Pin
Henry Minute4-May-09 10:10
Henry Minute4-May-09 10:10 
GeneralRe: need help with rowid values Pin
MeRoX4-May-09 10:14
MeRoX4-May-09 10:14 
GeneralRe: need help with rowid values Pin
Henry Minute4-May-09 10:41
Henry Minute4-May-09 10:41 
Questionneed an old Sybase ODBC driver Pin
AhmedOsamaMoh4-May-09 4:30
AhmedOsamaMoh4-May-09 4:30 
AnswerRe: need an old Sybase ODBC driver Pin
riced4-May-09 6:03
riced4-May-09 6:03 
GeneralRe: need an old Sybase ODBC driver Pin
AhmedOsamaMoh4-May-09 6:10
AhmedOsamaMoh4-May-09 6:10 
QuestionERROR Pin
kibromg4-May-09 1:39
kibromg4-May-09 1:39 
AnswerRe: ERROR Pin
Eddy Vluggen4-May-09 7:15
professionalEddy Vluggen4-May-09 7:15 
GeneralRe: ERROR Pin
kibromg5-May-09 1:03
kibromg5-May-09 1:03 

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.