我有兩個表tbl_item
和tbl_category
,現在我想要做的是選擇category.if category
被刪除的存儲過程應該返回1
其他0
刪除所選category
從tbl_catetgory
只有tbl_item
沒有記錄。請幫忙。檢查和刪除存儲過程
ALTER PROCEDURE [dbo].[Sp_DelItemcategory]
@code int
AS
BEGIN
declare @sql varchar(max)
DECLARE @data VARCHAR(50)
set @sql='SELECT Cat_code FROM dbo.Tbl_ItemMaster WHERE Cat_code = '[email protected];
declare dB_cursor cursor for
SELECT Cat_code FROM dbo.Tbl_ItemMaster WHERE Cat_code = @code
open dB_cursor
fetch next from dB_cursor into @data
WHILE @@FETCH_STATUS = 0
BEGIN
set @sql='delete from Tbl_ItemCategory where Cat_code='[email protected];
exec @sql
FETCH NEXT FROM db_cursor INTO @data
END
CLOSE db_cursor
DEALLOCATE db_cursor
END
任何企圖至今? – Paritosh
你做了什麼嗎?提出你的解決方案。 –
上面的sp會刪除找到記錄時,但我想刪除,如果沒有找到記錄 – Anand