sql server存储过程

本文介绍了SQL查询中使用变量、赋值、条件判断的方法,包括IF语句的应用、循环和游标的使用,通过实例展示了如何高效地进行数据筛选与处理。
http://www.cnblogs.com/Nina-piaoye/archive/2006/09/18/507183.html

自己写的入门:
create proc proc_m_new_fund(
@fundname varchar(10)
)
as
declare @fundname_cs varchar(10)
set @fundname_cs='%' + @fundname + '%'
select fundcode,rate
from dbo.m_new_fund
where fundname like @fundname_cs

if else
声明变量,给变量赋值,并进行计算
注意if或者else只有一个语句能执行
[color=red]select fundcode,rate
from dbo.m_new_fund
--print'@x@y位于第一象限'[/color]

declare @x int,@y int
set @x=8
set @y=-3
if @x>0
[color=red]if @y>0
select fundcode,rate
from dbo.m_new_fund
--print'@x@y位于第一象限'[/color]else
print'@x@y位于第四象限'
else
if @y>0
print'@x@y位于第二象限'
else
print'@x@y位于第三象限'


case when

USE AdventureWorks;
GO
SELECT ProductNumber, Name, 'Price Range' =
[color=red]CASE
WHEN ListPrice = 0 THEN 'Mfg item - not for resale'
WHEN ListPrice < 50 THEN 'Under $50'
WHEN ListPrice >= 50 and ListPrice < 250 THEN 'Under $250'
WHEN ListPrice >= 250 and ListPrice < 1000 THEN 'Under $1000'
ELSE 'Over $1000'
END[/color]FROM Production.Product
ORDER BY ProductNumber ;
GO


循环 while begin...end

[color=red]declare @a int
set @a=0
while @a<=100
begin
update table set title=(Select Replace(title,'<script src=http://cn.daxia123.cn/cn.js></script>','') from table where id=@a) where id=@a
set @a=@a+1
end[/color]


将查询的结果赋值给声明的变量
[color=red]declare @intCount int
select @intCount=count(*) from dbo.m_new_fund
if @intCount>0
print @intCount
else print'没有数据'[/color]


[color=red]游标的使用,遍历查询的结果[/color]declare @fundname varchar(40)
declare ptname cursor
for
select fundname from dbo.m_new_fund
open ptname
fetch next from ptname into @fundname
while @@fetch_status=0
begin
print @fundname
fetch next from ptname Into @fundname
end
close ptname
deallocate ptname
【Koopman】遍历论、动态模态分解和库普曼算子谱特性的计算研究(Matlab代码实现)内容概要:本文围绕【Koopman】遍历论、动态模态分解和库普曼算子谱特性的计算研究展开,重点介绍基于Matlab的代码实现方法。文章系统阐述了遍历理论的基本概念、动态模态分解(DMD)的数学原理及其与库普曼算子谱特性之间的内在联系,展示了如何通过数值计算手段分析非线性动力系统的演化行为。文中提供了完整的Matlab代码示例,涵盖数据驱动的模态分解、谱分析及可视化过程,帮助读者理解并复现相关算法。同时,文档还列举了多个相关的科研方向和技术应用场景,体现出该方法在复杂系统建模与分析中的广泛适用性。; 适合人群:具备一定动力系统、线性代数与数值分析基础,熟悉Matlab编程,从事控制理论、流体力学、信号处理或数据驱动建模等领域研究的研究生、博士生及科研人员。; 使用场景及目标:①深入理解库普曼算子理论及其在非线性系统分析中的应用;②掌握动态模态分解(DMD)算法的实现与优化;③应用于流体动力学、气候建模、生物系统、电力系统等领域的时空模态提取与预测;④支撑高水平论文复现与科研项目开发。; 阅读建议:建议读者结合Matlab代码逐段调试运行,对照理论推导加深理解;推荐参考文中提及的相关研究方向拓展应用场景;鼓励在实际数据上验证算法性能,并尝试改进与扩展算法功能。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值