sql server 综合使用的例子
exec sp_helptext prosampleoldstyle_usp
-- =============================================
-- =============================================
CREATE PROCEDURE [dbo].[prosampleoldstyle_usp]
@doccode varchar(20)
AS
BEGIN
declare @style varchar(50),
@docitem int,
@partid varchar(20),
@caidao varchar(50),
@Promatcode varchar(50),
@Promatname varchar(50),
@partname varchar(50),
@paradoccode varchar(20),
@special varchar(50),
@colortext varchar(50),
@uom varchar(20),
@rowid varchar(20),
@cltcode varchar(20),
@brand varchar(50)
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
IF db_name()='SYERP'
BEGIN
--*****************************
update SYPhoto.dbo.ProSampleImage set style=b.Style,image=b.StyleImage,inserttime=getdate()
from SYPhoto.dbo.ProSampleImage a inner join prosamplehd b on a.formid=b.formid and a.doccode=b.doccode
where a.formid=8205 and a.doccode=@doccode and b.StyleImage is not null
if @@rowcount=0
begin
insert into SYPhoto.dbo.ProSampleImage(formid,doccode,style,image)
select formid,doccode,style,StyleImage from prosamplehd with(nolock)
where doccode=@doccode and StyleImage is not null
end
update prosamplehd set StyleImage=NULL where doccode=@doccode and StyleImage is not null
END
--*****************************
if not exists(select 1 from prosampleitem with(nolock) where doccode=@doccode)
begin
select @style=style from prosamplehd with(nolock) where doccode=@doccode
select top 1 @paradoccode=h.doccode from prosamplehd h with(nolock) inner join prosampleitem t on h.doccode=t.doccode
where docstatus>=100 and style=@style and h.doccode<>@doccode
order by h.docdate desc
--游标取出同一个旧型体的部位信息
if @paradoccode is not null
begin
declare mycur cursor for select docitem,Partid,Partname,Caidao,Promatcode,Promatname,Special,ColorText,UOM
from proSampleitem with(nolock) where doccode=@paradoccode
open mycur
fetch next from mycur into @docitem,@partid,@partname,@caidao,@promatcode,@promatname,@special,@colortext,@uom
while(@@fetch_status=0)
begin
exec dbo.getxxxx @rowid output
--把该型体的部位信息插入新的样品制造单表体
insert into prosampleitem(doccode,rowid,docitem,partid,partname,caidao,promatcode,promatname,special,colortext,uom)
values(@doccode,@rowid,@docitem,@partid,@partname,@caidao,@promatcode,@promatname,@special,@colortext,@uom)
fetch next from mycur into @docitem,@partid,@partname,@caidao,@promatcode,@promatname,@special,@colortext,@uom
end
close mycur
deallocate mycur
end
end
--**************************************
select @cltcode=cltcode,@brand=brand from prosamplehd with(nolock) where doccode=@doccode
if not exists(select 1 from imatpub_card with(nolock) where cltcode=@cltcode and cardname=@brand)
begin
insert into imatpub_card(cltcode,cardname)
values(@cltcode,@brand)
end
END
exec sp_helptext prosampleoldstyle_usp
-- =============================================
-- Author: <方清海>
-- Create date: <2008-10-07>
-- Description: <如果是旧型体,则自动把部位信息写入样品制造单>
-- =============================================
CREATE PROCEDURE [dbo].[prosampleoldstyle_usp]
@doccode varchar(20)
AS
BEGIN
declare @style varchar(50),
@docitem int,
@partid varchar(20),
@caidao varchar(50),
@Promatcode varchar(50),
@Promatname varchar(50),
@partname varchar(50),
@paradoccode varchar(20),
@special varchar(50),
@colortext varchar(50),
@uom varchar(20),
@rowid varchar(20),
@cltcode varchar(20),
@brand varchar(50)
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
IF db_name()='SYERP'
BEGIN
--*****************************
update SYPhoto.dbo.ProSampleImage set style=b.Style,image=b.StyleImage,inserttime=getdate()
from SYPhoto.dbo.ProSampleImage a inner join prosamplehd b on a.formid=b.formid and a.doccode=b.doccode
where a.formid=8205 and a.doccode=@doccode and b.StyleImage is not null
if @@rowcount=0
begin
insert into SYPhoto.dbo.ProSampleImage(formid,doccode,style,image)
select formid,doccode,style,StyleImage from prosamplehd with(nolock)
where doccode=@doccode and StyleImage is not null
end
update prosamplehd set StyleImage=NULL where doccode=@doccode and StyleImage is not null
END
--*****************************
if not exists(select 1 from prosampleitem with(nolock) where doccode=@doccode)
begin
select @style=style from prosamplehd with(nolock) where doccode=@doccode
select top 1 @paradoccode=h.doccode from prosamplehd h with(nolock) inner join prosampleitem t on h.doccode=t.doccode
where docstatus>=100 and style=@style and h.doccode<>@doccode
order by h.docdate desc
--游标取出同一个旧型体的部位信息
if @paradoccode is not null
begin
declare mycur cursor for select docitem,Partid,Partname,Caidao,Promatcode,Promatname,Special,ColorText,UOM
from proSampleitem with(nolock) where doccode=@paradoccode
open mycur
fetch next from mycur into @docitem,@partid,@partname,@caidao,@promatcode,@promatname,@special,@colortext,@uom
while(@@fetch_status=0)
begin
exec dbo.getxxxx @rowid output
--把该型体的部位信息插入新的样品制造单表体
insert into prosampleitem(doccode,rowid,docitem,partid,partname,caidao,promatcode,promatname,special,colortext,uom)
values(@doccode,@rowid,@docitem,@partid,@partname,@caidao,@promatcode,@promatname,@special,@colortext,@uom)
fetch next from mycur into @docitem,@partid,@partname,@caidao,@promatcode,@promatname,@special,@colortext,@uom
end
close mycur
deallocate mycur
end
end
--**************************************
select @cltcode=cltcode,@brand=brand from prosamplehd with(nolock) where doccode=@doccode
if not exists(select 1 from imatpub_card with(nolock) where cltcode=@cltcode and cardname=@brand)
begin
insert into imatpub_card(cltcode,cardname)
values(@cltcode,@brand)
end
END
uf_GetSpellCode -- ============================================= -- Author: <Author,,Name> -- Create date: <Create Date,,> -- Description: <Description,,> -- ============================================= CREATE TRIGGER wzh_cfqdemo1
ON WZH_CKZL AFTER insert
YF
AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; DECLARE @msg VARCHAR()
DECLARE @cltname VARCHAR()
SELECT @cltname=cltname from WZH_CKZL select @msg = dbo.uf_GetSpellCode(cltname) from WZH_CKZL
update WZH_CKZL set fastcode=@msg where cltname =@cltname END
sql server 综合使用的例子的更多相关文章
- java当中JDBC当中请给出一个sql server的stored procedure例子
3.sql server的stored procedure例子: import java.sql.*;public class StoredProc0 {public static void main ...
- SQL Server Service Broker 简单例子 (转)
SQL Server Service Broker服务体系结构 消息类型 — 定义应用程序间交换的消息的名称.还可以选择是否验证消息.约定 — 指定给定会话中的消息方向和消息类型.队列 — 存储消息. ...
- sql server 的osql 使用例子
一次性执行一个语句并输出到文件: osql -Usa -dSCGWYDJ2012 -P -S192.168.56.1 -Q "exit( SELECT top 1 * FROM A08)&q ...
- sql server 视图 的一个例子
这是一个 有点复杂的查询.我现在 想把他封装 成 视图 其中 B.RecordID= 41 提供给 视图外查询. create view view_UserRecord as select Rec ...
- python 连接sql server
linux 下pymssql模块的安装 所需压缩包:pymssql-2.1.0.tar.bz2freetds-patched.tar.gz 安装: tar -xvf pymssql-2.1.0.tar ...
- 第八篇 SQL Server安全数据加密
本篇文章是SQL Server安全系列的第八篇,详细内容请参考原文. Relational databases are used in an amazing variety of applicatio ...
- 【译】第八篇 SQL Server安全数据加密
本篇文章是SQL Server安全系列的第八篇,详细内容请参考原文. Relational databases are used in an amazing variety of applicatio ...
- sql server自定义排序
方法一: 比如需要对SQL表中的字段NAME进行如下的排序:张三(Z)李四(L)王五(W)赵六(Z) 按照sql中的默认排序规则,根据字母顺序(a~z)排,结果为:李四 王五 赵六 张三 自定义排序 ...
- sql server函数(isnull,charindex,cast,自定义函数)
SELECT charindex( CAST ( dbo.ufn_IsNullOrEmpty ('109722A3-622D-4FD4-A060-0287C933A89E', a.OUID) AS V ...
随机推荐
- 以php中的比较运算符操作整型,浮点型,字符串型,布尔型和空类型
字符,数字,特殊符号的比较依赖ASC II表,本表原先有127个,后来又扩充了一些,里面包含了奇奇奇怪的符号. ASC II表 https://baike.baidu.com/item/ASCII/3 ...
- 测试库异常down分析(abnormal instance termination)
客户测试库,down问题分析,根据alert 的问题指向,实例异常终止,但是无其它有价值的信息 Terminating the Instance Due to Error Out-Of-Memory( ...
- Dijkstra算法正确性证明
问题:求图中点1到其他各点的最短距离 策略: 1.把起点1放入初始集合Set中,从剩余的点中,选取到Set(此时Set中只有1个点)距离最近的点,并入集合Set中, 2.从剩余的点中,找经过集合Set ...
- robot framework 怎么验证搜索无记录,页面元素不存在
假设你要验证搜索无记录,页面元素不存在,假设我搜索的文本为你好 页面展示为如下 搜索:你好 假设页面搜索有结果: 你好 class=vtext 你好1 class=vtext 你好2 class ...
- 节日营销!这样搞-App运营日常
节日送礼需求日益增长,当儿女们有了购买需求的时候,商家如何突出重围,成为孝子们的首选?如何做好节日营销?几个经验分享一下: 1.抓住节日特色 结合节日风格特色,营造节日气氛,如母亲节这种节日,主要体现 ...
- VBA数组(十四)
我们都知道,一个变量是一个存储值的容器. 有时,开发人员希望一次可以在一个变量中保存多个值. 当一系列值存储在单个变量中时,则称为数组变量. 数组声明 数组声明的方式与声明变量相同,只是数组变量的声明 ...
- element-ui DatePicker 日期选择器 让结束日期大于开始日期
element-ui DatePicker 日期选择器 <el-date-picker v-model="addForm.startDate" type="dat ...
- idea 实用插件
尊重劳动成果,本插件的整理原文出自:https://blog.csdn.net/weixin_41846320/article/details/82697818,感谢老铁的辛苦原创. 插件安装方式: ...
- UNIX常用shell
/bin/sh Bourne shell 它是Unix的默认Shell,也是其它Shell的开发基础.Bourne Shell在编程方面相当优秀,但在处理与用户的交互方面不如其它几种Shell /bi ...
- flutter入门之常见的flutter问题汇总(转)
1. 使用AppBar后如何去掉左边的返回箭头.左边的图标对应的是leading,源代码如下(吐槽一下,CSDN暂不支持dart语言): Widget leading = widget.leading ...