Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 please help!

Author  Topic 

Reg
Starting Member

7 Posts

Posted - 2007-12-07 : 06:06:32
I have a table called "jbtest"
eg..jbtest
jbID int,
jpostname varchar(200)

I have a select CURSOR ,,eg...

DECLARE jp_Cursor CURSOR FOR
SELECT jpid, jpostname
FROM jbtest

OPEN jp_Cursor

FETCH NEXT FROM jp_Cursor
WHILE @@FETCH_STATUS = 0
BEGIN
FETCH NEXT FROM jp_Cursor
END

CLOSE jp_Cursor
DEALLOCATE jp_Cursor


I have inserted data into [colun_jpostname]
How can i delete repeating "jpostname" from using CURSOR?

Please !


Rg

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-12-07 : 06:39:39
You mean you want to delete duplicate records for column jpostname?



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-07 : 07:14:40
Can you explain what you are trying to do?
Probably you need distinct jpostname

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Reg
Starting Member

7 Posts

Posted - 2007-12-10 : 00:51:49
yes, I am trying to delete duplicate jpostname.

select * from jbtest where jpostname > 1

if i write like this.... ERROR MGS...Conversion failed when converting the varchar value 'Cadet Planter' to data type int.



Rg
Go to Top of Page

Reg
Starting Member

7 Posts

Posted - 2007-12-10 : 01:01:03
or
delete from jbtest where jpostname > 1

I am still geting the same ERROR MGS....Conversion failed when converting the varchar value 'Cadet Planter' to data type int.

Rg
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-10 : 01:07:53
Refer this topic and apply one of the approaches
http://sqlteam.com/forums/topic.asp?TOPIC_ID=6256

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Reg
Starting Member

7 Posts

Posted - 2007-12-19 : 02:15:00
I got it!

Thank you madhivanan

Rg
Go to Top of Page
   

- Advertisement -