Monday, March 22, 2010

Remove Duplicate values

CREATE TABLE dbo.authors
(
PK_Column INT IDENTITY,
Authorname VARCHAR(50)
)
GO
INSERT dbo.authors(Authorname)
SELECT 'Author1'
UNION ALL SELECT 'Author1'
UNION ALL SELECT 'Author1'
UNION ALL SELECT 'Author2'
UNION ALL SELECT 'Author2'
UNION ALL SELECT 'Author3'
UNION ALL SELECT 'Author3'
UNION ALL SELECT 'Author4'
GO
SELECT * FROM dbo.authors
Go
DELETE authors
FROM authors a
LEFT OUTER JOIN
(
SELECT Authorname, pk_column = MIN(PK_Column)
FROM dbo.authors
GROUP BY Authorname
) x
ON a.pk_column = x.pk_column
WHERE x.pk_column IS NULL

Monday, March 15, 2010

DoEvents in vb.net

If you call DoEvents in your code, your application can handle the other events.

Syntex:

Application.doevents()