惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

雷峰网
雷峰网
WordPress大学
WordPress大学
MyScale Blog
MyScale Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
The Blog of Author Tim Ferriss
U
Unit 42
罗磊的独立博客
G
Google Developers Blog
Microsoft Azure Blog
Microsoft Azure Blog
The Cloudflare Blog
aimingoo的专栏
aimingoo的专栏
Vercel News
Vercel News
N
Netflix TechBlog - Medium
H
Hackread – Cybersecurity News, Data Breaches, AI and More
云风的 BLOG
云风的 BLOG
Hugging Face - Blog
Hugging Face - Blog
大猫的无限游戏
大猫的无限游戏
F
Fortinet All Blogs
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
小众软件
小众软件
博客园 - 【当耐特】
H
Help Net Security
The GitHub Blog
The GitHub Blog

博客园 - 珂儿

谈话技巧 用户中心 - 博客园 用户中心 - 博客园 【转载】 正则表达式 致谢 转载:Prototype.js的中文使用手册 C# Program Output Redirect 猫猫感冒了 从我的衣着改变说起 天无绝人之路 Job hunting准备系列一——关于搜索引擎技术 读书疑问汇总 算法题目汇总 How to influence people and win friends 项目经历总结——IBM实习总结 C++程序设计学习笔记 求职经验汇总 《编程之美》笔记
Notes of Store Procedure
珂儿 · 2009-01-05 · via 博客园 - 珂儿

I have not done anything related to this knowledge before, so this time I have met with many questions and problems when I have to use store procedure to finish some database operation. In order to make myself know more, I note down some thing here firstly and I would try to refine these materials to a real note if I had sometime in future.

CREATE PROCEDURE [dbo].[zhangke]

AS

BEGIN

declare @tempOfferId char(50)

declare @topCats varchar(200)

declare @subCats varchar(300)

DECLARE rs CURSOR LOCAL SCROLL FOR

select offer_id from compare_task_detail_result

open rs

fetch next from rs into @tempOfferId

WHILE @@FETCH_STATUS = 0

Begin

select @topCats = Category,@subCats = ItemProviderCategory from [JellyFish].[dbo].[20080922] where Id=@tempOfferId

update compare_task_detail_result

set offer_category=@topCats,offer_ItemProviderCategory=@subCats

where offer_id = @tempOfferId

fetch next from rs into @tempOfferId

end

close rs

END

USE [temp]

GO

/****** Object: StoredProcedure [dbo].[updateTempTable] Script Date: 01/06/2009 12:57:25 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE PROCEDURE [dbo].[updateTempTable]

@tbname varchar(100)

AS

BEGIN

declare @tempOfferId char(50)

declare @topCats varchar(200)

declare @subCats varchar(300)

declare @sqlStr nvarchar(1000)

DECLARE rs CURSOR LOCAL SCROLL FOR

select offer_id from compare_task_detail_result

open rs

fetch next from rs into @tempOfferId

WHILE @@FETCH_STATUS = 0

Begin

set @sqlStr=' select @topCats = Category,@subCats = ItemProviderCategory from ' + @tbname + ' where Id='+@tempOfferId;

EXEC SP_EXECUTESQL @sqlStr,N'@topCats varchar(200) out,@subCats varchar(300) out', @topCats out,@subCats out

update compare_task_detail_result

set offer_category=@topCats,offer_ItemProviderCategory=@subCats

where offer_id = @tempOfferId

fetch next from rs into @tempOfferId

end

close rs

END

USE [temp]

GO

/****** Object: StoredProcedure [dbo].[updateTempTable2] Script Date: 01/06/2009 16:39:04 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE PROCEDURE [dbo].[updateTempTable2]

--@tbname varchar(1000)

AS

BEGIN

declare @tempOfferId char(50)

declare @topCats varchar(200)

declare @subCats varchar(300)

declare @sqlStr nvarchar(1000)

DECLARE rs CURSOR LOCAL SCROLL FOR

select offer_id from compare_task_detail_result

open rs

fetch next from rs into @tempOfferId

WHILE @@FETCH_STATUS = 0

Begin

--set @sqlStr=' select @topCatsOut = Category,@subCatsOut = ItemProviderCategory from ' + @tbname + ' where Id='+@tempOfferId;

--EXEC SP_EXECUTESQL @sqlStr,N'@topCatsOut varchar(200) OUTPUT,@subCatsOut varchar(300) OUTPUT', @topCatsOut = @topCats OUTPUT,@subCatsOut = @subCats OUTPUT

select @topCats = Category,@subCats = ItemProviderCategory from [JellyFish].[dbo].[20080922] where Id=@tempOfferId

update compare_task_detail_result

set offer_category=@topCats,offer_ItemProviderCategory=@subCats

where offer_id = @tempOfferId

fetch next from rs into @tempOfferId

end

close rs

END