Click here to Skip to main content
16,012,198 members
Home / Discussions / Database
   

Database

 
GeneralRe: Sql query Pls help Pin
Michael P Butler23-Aug-06 23:42
Michael P Butler23-Aug-06 23:42 
GeneralRe: Sql query Pls help Pin
vipinpaliwal198024-Aug-06 7:47
vipinpaliwal198024-Aug-06 7:47 
GeneralRe: Sql query Pls help Pin
_AK_24-Aug-06 23:51
_AK_24-Aug-06 23:51 
Questionremove duplicate records Pin
hublikitty23-Aug-06 20:19
hublikitty23-Aug-06 20:19 
AnswerRe: remove duplicate records [modified] Pin
BalasahebK23-Aug-06 20:53
BalasahebK23-Aug-06 20:53 
GeneralRe: remove duplicate records Pin
hublikitty23-Aug-06 22:54
hublikitty23-Aug-06 22:54 
GeneralRe: remove duplicate records Pin
BalasahebK23-Aug-06 23:12
BalasahebK23-Aug-06 23:12 
AnswerRe: remove duplicate records Pin
Eric Dahlvang24-Aug-06 8:14
Eric Dahlvang24-Aug-06 8:14 
SQL Server
Deleting Rows in Result Sets[^]

But, that will probably not work because:
Before a cursor can be used by a positioned UPDATE or DELETE statement, the SELECT statement in the cursor declaration must contain the FOR BROWSE option. (The Microsoft SQL Server 2000 FOR BROWSE option is similar to the FOR UPDATE option in other SQL databases, but you must use SQL Server syntax.) To use the FOR BROWSE option, the table must have both a unique index and a timestamp column.

You could do this:
BEGIN TRANSACTION
CREATE TABLE dbo.Tmp_MyTestingTable
	(
	TestCol varchar(50) NULL
	)  ON [PRIMARY]

INSERT INTO dbo.Tmp_MyTestingTable (TestCol)
		SELECT DISTINCT TestCol FROM dbo.MyTestingTable TABLOCKX

DROP TABLE dbo.MyTestingTable

EXECUTE sp_rename 'dbo.Tmp_MyTestingTable', 'MyTestingTable'

COMMIT


-----------------------------
LATER NOTE: I tried the cursor anyway...and it DOES work.
DECLARE @cCol varchar(50)

DECLARE MyCursor CURSOR FOR
    SELECT testcol
    FROM MyTestingTable 

OPEN MyCursor
FETCH NEXT FROM MyCursor INTO @cCol
WHILE @@FETCH_STATUS = 0
BEGIN
	if(SELECT COUNT(*) FROM MyTestingTable WHERE TestCol = @cCol)>1
	BEGIN
		DELETE FROM MyTestingTable
			WHERE CURRENT OF MyCursor
	END
	FETCH NEXT FROM MyCursor INTO @cCol
END
CLOSE MyCursor
DEALLOCATE MyCursor
GO


--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters

AnswerRe: remove duplicate records Pin
Skanless26-Aug-06 9:02
Skanless26-Aug-06 9:02 
QuestionProblem installing SQL 2005 Express Pin
data1423-Aug-06 19:21
data1423-Aug-06 19:21 
AnswerRe: Problem installing SQL 2005 Express Pin
Jerry Hammond24-Aug-06 5:30
Jerry Hammond24-Aug-06 5:30 
GeneralRe: Problem installing SQL 2005 Express Pin
data1426-Aug-06 10:46
data1426-Aug-06 10:46 
QuestionHow to save 'Migración Líneas 1&2' in SQL SERVER 2000 Pin
BalasahebK23-Aug-06 18:33
BalasahebK23-Aug-06 18:33 
AnswerRe: How to save 'Migración Líneas 1&2' in SQL SERVER 2000 Pin
Colin Angus Mackay23-Aug-06 22:36
Colin Angus Mackay23-Aug-06 22:36 
GeneralRe: How to save 'Migración Líneas 1&2' in SQL SERVER 2000 [modified] Pin
BalasahebK23-Aug-06 23:07
BalasahebK23-Aug-06 23:07 
GeneralRe: How to save 'Migración Líneas 1&2' in SQL SERVER 2000 Pin
Colin Angus Mackay24-Aug-06 5:24
Colin Angus Mackay24-Aug-06 5:24 
AnswerRe: How to save 'Migración Líneas 1&2' in SQL SERVER 2000 Pin
Mike Dimmick24-Aug-06 0:11
Mike Dimmick24-Aug-06 0:11 
GeneralRe: How to save 'Migración Líneas 1&2' in SQL SERVER 2000 [modified] Pin
BalasahebK24-Aug-06 0:58
BalasahebK24-Aug-06 0:58 
QuestionOledbparameter names with spaces Pin
GrindEspresso23-Aug-06 14:48
GrindEspresso23-Aug-06 14:48 
AnswerRe: Oledbparameter names with spaces Pin
Navi1523-Aug-06 19:03
Navi1523-Aug-06 19:03 
GeneralRe: Oledbparameter names with spaces Pin
GrindEspresso23-Aug-06 21:09
GrindEspresso23-Aug-06 21:09 
QuestionWhat is the simplest statement to insert a bitmap into Image column? Pin
pedestrian79723-Aug-06 13:55
pedestrian79723-Aug-06 13:55 
AnswerRe: What is the simplest statement to insert a bitmap into Image column? Pin
Jerry Hammond23-Aug-06 17:01
Jerry Hammond23-Aug-06 17:01 
QuestionDynamic EXEC [modified] Pin
em00guy23-Aug-06 8:28
em00guy23-Aug-06 8:28 
AnswerRe: Dynamic EXEC Pin
em00guy23-Aug-06 9:47
em00guy23-Aug-06 9:47 

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.