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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - mjgforever

51 条 ActionScript 3.0 和 Flex 优化技术与实践 open source Flex project list Open Source Replication and Synchronization Tools Written in Java 用SyncML进行异构数据库复制 WF学习系列之六:工作流和宿主程序通讯异常引发的思考 - mjgforever - 博客园 WF学习系列之五:状态机工作流学习 WF学习系列之四:顺序工作流控制台应用程序模板介绍 WF学习系列之三:RuleSet知识点概述 WF学习系列之二:开发工作流知识点概述 WF学习系列之一:WF基本知识点概述 abstract, virtual, override, new 关键字的用法 ArcIMS 安装指南 Google推出Protocol Buffers:争夺网络时代数据格式 Protocol Buffers 简介 Protocol Buffers:Google 的数据交换格式 - mjgforever 微软vs.VMware:虚拟化中的真实战争 - mjgforever 文本文件与二进制文件 字符编码简介:ASCII,Unicode,UTF-8,GB2312 Adobe Flex的十大误解
sp_executesql和临时表的用法
mjgforever · 2009-08-19 · via 博客园 - mjgforever

        相比oracle,sqlserver对数据集的操作不直观,而且比较麻烦。我就遇到这样的一种情形,想获取 exec sp_executesql @sql返回的数据集,然后对返回的数据集进行遍历。
        起初,我利用游标来操作返回的数据集,但是游标不支持 exec sp_executesql @sql 返回的数据集,于是我想到了临时表,但很快发现,利用 exec sp_executesql 操作创建的临时表,其作用范围只存在于当前语句中,它后面的语句就不能再引用这个临时表了。
        也许有人会说,先把临时表定义好,不就可以了。其实,我要做的这个工作,临时表的列是变化的,所以不能先定义临时表。这是我想到了全局临时表,把查询的数据集存入全局临时表中。
        下面给出sqlserver和oracle进行此类操作的代码,希望能对大家有所帮助。

Code

oracle代码操作如下:

Code

如果大家更好的,解决该问题的方法,即时讨论。