Click here to Skip to main content
15,926,281 members
Home / Discussions / Database
   

Database

 
GeneralRe: How i can write query return the douplicate record with deffrint IDs ?! Pin
AJ Hoge7-Dec-09 0:41
AJ Hoge7-Dec-09 0:41 
GeneralRe: How i can write query return the douplicate record with deffrint IDs ?! Pin
dan!sh 7-Dec-09 1:05
professional dan!sh 7-Dec-09 1:05 
GeneralRe: How i can write query return the douplicate record with deffrint IDs ?! Pin
AJ Hoge7-Dec-09 2:05
AJ Hoge7-Dec-09 2:05 
AnswerRe: How i can write query return the douplicate record with deffrint IDs ?! Pin
Luc Pattyn7-Dec-09 0:52
sitebuilderLuc Pattyn7-Dec-09 0:52 
GeneralRe: How i can write query return the douplicate record with deffrint IDs ?! Pin
AJ Hoge7-Dec-09 1:45
AJ Hoge7-Dec-09 1:45 
AnswerRe: How i can write query return the douplicate record with deffrint IDs ?! Pin
puri keemti7-Dec-09 1:03
puri keemti7-Dec-09 1:03 
GeneralRe: How i can write query return the douplicate record with deffrint IDs ?! Pin
AJ Hoge7-Dec-09 2:12
AJ Hoge7-Dec-09 2:12 
GeneralRe: How i can write query return the douplicate record with deffrint IDs ?! [modified] Pin
Blue_Boy7-Dec-09 2:43
Blue_Boy7-Dec-09 2:43 
Hi,
This query works for SQL Server2005,but try to convert for Access2007.

A)
CREATE TABLE #tmpData
(
	id INT IDENTITY(1,1),
	custname VARCHAR(MAX)
)

INSERT INTO #tmpData
SELECT m.Customername 
FROM mytable1 m 
GROUP BY m.Customername,m.phonenumber,m.city,m.street HAVING COUNT(m.Customername)>1

DECLARE @i AS INT
DECLARE @query AS nvarCHAR(MAX)

SET @i=0
SET @query = 'select * from mytable1 where customername in ('

WHILE(@i<(SELECT COUNT(*) FROM #tmpData))
BEGIN
	SET @i=@i+1
	SET @query=@query+(SELECT char(39)+custname + char(39) FROM #tmpData WHERE id=@i)+',' 
	
END
SET @query=SUBSTRING(@query,1,LEN(@query)-1)
SET @query=@query+')'

EXEC(  @query)
DROP TABLE #tmpData



I just played around and found too way to work for Access (I tested it on Access 2003 and not for 2007 version,but i think it should work too for Access2007 version)
B)

select a.id,a.Customername , a.phonenumber, a.city, a.street     
from mytable1 a
inner join 
(select Customername , phonenumber, city, street
from mytable1
group by customername,phonenumber,city,street
having count(*) > 1) b  
on a.Customername = b.Customername



I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.

www.aktualiteti.com

modified on Monday, December 7, 2009 9:32 AM

AnswerRe: How i can write query return the douplicate record with deffrint IDs ?! Pin
Niladri_Biswas7-Dec-09 17:33
Niladri_Biswas7-Dec-09 17:33 
QuestionValidation Rule In SQL Server 2005 Pin
hussain.attiya6-Dec-09 21:09
hussain.attiya6-Dec-09 21:09 
AnswerRe: Validation Rule In SQL Server 2005 Pin
dan!sh 6-Dec-09 21:50
professional dan!sh 6-Dec-09 21:50 
GeneralRe: Validation Rule In SQL Server 2005 Pin
hussain.attiya6-Dec-09 21:59
hussain.attiya6-Dec-09 21:59 
AnswerRe: Validation Rule In SQL Server 2005 Pin
Mycroft Holmes6-Dec-09 22:36
professionalMycroft Holmes6-Dec-09 22:36 
GeneralRe: Validation Rule In SQL Server 2005 Pin
hussain.attiya6-Dec-09 23:02
hussain.attiya6-Dec-09 23:02 
GeneralRe: Validation Rule In SQL Server 2005 Pin
Mycroft Holmes6-Dec-09 23:50
professionalMycroft Holmes6-Dec-09 23:50 
AnswerRe: Validation Rule In SQL Server 2005 Pin
puri keemti7-Dec-09 1:04
puri keemti7-Dec-09 1:04 
AnswerRe: Validation Rule In SQL Server 2005 Pin
Niladri_Biswas7-Dec-09 17:42
Niladri_Biswas7-Dec-09 17:42 
QuestionCustom sort in SQL Server Pin
Ma tju6-Dec-09 18:36
Ma tju6-Dec-09 18:36 
AnswerRe: Custom sort in SQL Server Pin
Mycroft Holmes6-Dec-09 18:42
professionalMycroft Holmes6-Dec-09 18:42 
GeneralRe: Custom sort in SQL Server Pin
Ma tju6-Dec-09 18:48
Ma tju6-Dec-09 18:48 
AnswerRe: Custom sort in SQL Server Pin
Shameel6-Dec-09 23:37
professionalShameel6-Dec-09 23:37 
GeneralRe: Custom sort in SQL Server Pin
Mycroft Holmes7-Dec-09 0:07
professionalMycroft Holmes7-Dec-09 0:07 
GeneralRe: Custom sort in SQL Server Pin
Shameel7-Dec-09 6:57
professionalShameel7-Dec-09 6:57 
GeneralRe: Custom sort in SQL Server Pin
Ma tju7-Dec-09 14:31
Ma tju7-Dec-09 14:31 
AnswerRe: Custom sort in SQL Server Pin
Niladri_Biswas7-Dec-09 17:51
Niladri_Biswas7-Dec-09 17:51 

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.