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.
| Author |
Topic |
|
hemanth
Starting Member
1 Post |
Posted - 2002-10-24 : 08:27:02
|
| Hi allIam trying to run a stored procedure written in an script file as below/****** Object: Stored Procedure dbo.CATEGORY_DELETE Script Date: 07/22/2002 1:36:45 PM ******/CREATE PROCEDURE CATEGORY_DELETE@resource_struct_id numeric(9),@status_ok smallint=0 outputasDECLARE @resource_id numeric--FETCH THE RESOURCEID AND RESOURCETYPEDECLARE CUR_RESOURCE CURSOR LOCAL FOR select resource_id from resource_manager where resource_struct_id=@resource_struct_idOPEN CUR_RESOURCEFETCH CUR_RESOURCE INTO @resource_idWHILE(@@FETCH_STATUS=0)BEGIN--SELECT THE RESOURCEID AND TYPE FROM THE RESOURCEMANAGER TABLEFETCH CUR_RESOURCE INTO @resource_idENDCLOSE CUR_RESOURCEDEALLOCATE CUR_RESOURCEIF EXISTS(SELECT RESOURCE_STRUCT_ID FROM RESOURCE_STRUCT WHERE resource_struct_prev=@resource_struct_id) BEGIN SET @status_ok=0 ENDELSE BEGIN delete from resource_manager where resource_id=@resource_id delete from resource_struct where resource_struct_id=@resource_struct_id SET @status_ok=1 ENDGOThe above stored procedure shows an syntax error at line numbers where i have used the "DELETE FROM" to delete the rows in a table.Also i would like to know the impact/difference of using"Delete from tablename where col_name='abc'and"Delete tablename where col_name='abc'Do help me in this regard!!!with regardsHemanth |
|
|
ValterBorges
Master Smack Fu Yak Hacker
1429 Posts |
Posted - 2002-10-24 : 08:58:02
|
| FROM BOL:FROMIs an optional keyword that can be used between the DELETE keyword and the target table_name, view_name, or rowset_function_limited. Can you post the error your getting.I don't think you need a cursor at all, can you post your table structure, some sample data and expected results and someone can help you transform this cursor solution to a set based solution. |
 |
|
|
|
|
|