SP游标
---------------------------------------------------------------------------------------
DECLARE @CURSOR CURSOR
SET @CURSOR=CURSOR FOR
SELECT [ID], [标题], [内容], [出处], [时间], [类别ID], [品牌ID], [点击数]
FROM [GKShop].[dbo].[新闻采集]
OPEN @CURSOR
DECLARE @ID BIGINT
DECLARE @TITLE NVARCHAR(100)
DECLARE @CONTENT NVARCHAR(4000)
DECLARE @SOURCE NVARCHAR(100)
DECLARE @TIME NVARCHAR(100)
DECLARE @CLASSID NVARCHAR(100)
DECLARE @BRANDID NVARCHAR(100)
DECLARE @CLICKCOUNT NVARCHAR(100)
FETCH NEXT FROM @CURSOR
INTO @ID,@TITLE,@CONTENT,@SOURCE,@TIME,@CLASSID,@BRANDID,@CLICKCOUNT
WHILE @@FETCH_STATUS=0
BEGIN
IF NOT(@TITLE LIKE '' OR @TITLE IS NULL OR @CONTENT LIKE '' OR @CONTENT IS NULL)
INSERT INTO dbo.gk_sys_News(Title,Author,Source,Content,AddTime,ClassID,AuthTime,ClickCount,BrandID,IsDelete,IsAuth)
VALUES(@TITLE,'佚名',@SOURCE,@CONTENT,CONVERT(DATETIME,@TIME),@CLASSID,CONVERT(DATETIME,@TIME),@CLICKCOUNT,@BRANDID,0,1)
DELETE FROM [GKShop].[dbo].[新闻采集] WHERE [ID]=@ID
FETCH NEXT FROM @CURSOR
INTO @ID,@TITLE,@CONTENT,@SOURCE,@TIME,@CLASSID,@BRANDID,@CLICKCOUNT
END
---------------------------------------------------------------------------------------