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

推荐订阅源

Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
A
About on SuperTechFans
IT之家
IT之家
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Blog — PlanetScale
Blog — PlanetScale
aimingoo的专栏
aimingoo的专栏
云风的 BLOG
云风的 BLOG
The GitHub Blog
The GitHub Blog
Vercel News
Vercel News
G
Google Developers Blog
J
Java Code Geeks
宝玉的分享
宝玉的分享
T
Tailwind CSS Blog
Cloudbric
Cloudbric
L
LINUX DO - 最新话题
MyScale Blog
MyScale Blog
H
Heimdal Security Blog
PCI Perspectives
PCI Perspectives
Attack and Defense Labs
Attack and Defense Labs
S
Security @ Cisco Blogs
Latest news
Latest news
I
Intezer
L
Lohrmann on Cybersecurity
C
CXSECURITY Database RSS Feed - CXSecurity.com
月光博客
月光博客
T
Threatpost
博客园 - 【当耐特】
S
Schneier on Security
P
Privacy International News Feed
G
GRAHAM CLULEY
T
Tenable Blog
AWS News Blog
AWS News Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
雷峰网
雷峰网
博客园 - Franky
Engineering at Meta
Engineering at Meta
美团技术团队
S
Secure Thoughts
T
Troy Hunt's Blog
Microsoft Security Blog
Microsoft Security Blog
SecWiki News
SecWiki News
V
Visual Studio Blog
人人都是产品经理
人人都是产品经理
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Cisco Talos Blog
Cisco Talos Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Martin Fowler
Martin Fowler
Webroot Blog
Webroot Blog
Google DeepMind News
Google DeepMind News
H
Hackread – Cybersecurity News, Data Breaches, AI and More

博客园 - zqstc

The following module was built either with optimizations enabled or witherout debug information QQQQQQQ sql 2005 分页 Java学习路线图 SQL 链接服务器及权限限制 apache与tomcat整合 eclipse学习 Eclipse3.6版本汉化 Eclipse 的版本历史 MOSS2007下载 MOSS安装全过程 SQL简繁体转换 SQL2000 递归问题 Tomcat+JSP学习一 JavaScript---radio组 Office2003关联的word文档图标无法显示解决方案 用于主题检测的临时日志(f328f8e5-34df-4189-bccc-47d1025dc7dd - 3bfe001a-32de-4114-a6b4-4005b770f6d7) wa gaga Requested registry access is not allowed(不允许所请求的注册表访问权)
SQL学习 continue~~
zqstc · 2010-03-29 · via 博客园 - zqstc

游标 @@FETCH_STATUS   =0 Fetch语句成功 =-1 Fetch语句失败或不在结果集中    =-2 提取的行不存在

通过@@FETCH_STATUS做循环

create table #temp
(
activityid nvarchar(4),
acttype nvarchar(10)
)
declare my_cursor cursor
for select activityid,acttype
from activity
order by activityid desc

open my_cursor
declare
@id nvarchar(4),
@acttype nvarchar(10)

FETCH next from my_cursor
INTO @id,@acttype

while(@@fetch_status=0)
begin
if(Not Exists(select * from #temp Where activityid=@id))
insert into #temp select @id,@acttype
fetch next from my_cursor into @id,@acttype
end
CLOSE my_cursor
DEALLOCATE my_cursor
select * from #temp
drop table #temp

ps:char存取的值会乱码,nvarchar即可解决