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 ...
随机推荐
- 全面优化MySQL
MySQL性能瓶颈原因 硬件.系统因素 CPU 磁盘I/O 网络性能 操作系统争用 MySQL相关因素 数据库设计 索引.数据类型 应用程序性能 特定请求.短时事务 配置变量 缓冲区.高速缓存.Inn ...
- stm32f103的低功耗开启和关闭
stm32f103低功耗分为WFI等待中断和WFE等待事件,我只用到等待中断,这里没有细究. 待机模式最低功耗2uA,只有备份寄存器和待机电路供电,PLL,HSI,HSE断开,寄存器和SRAM复位,除 ...
- oracle-3-Linux-11g安装-图形安装
在安装系统时就安装了图形桌面 参考博客地址:https://www.cnblogs.com/tibit/p/6134150.html 未参考,只是感觉不错:https://blog.csdn.net/ ...
- js复制内容到粘贴板
点击右边内容:<span onclick="copyContent(this);" title="点击复制">啊,我被复制了</span> ...
- hdu 5432
Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he ...
- VBA子程序(十六)
子程序(Sub Procedures,也叫子过程)与函数类似,但有一些差异. 子过程不需要有返回一个值,而函数可能会或可能不会有返回一个值. 子程序可以不用call关键字来调用. 子程序总是包含在Su ...
- Linux 之 压缩解压缩
Linux中常见的压缩格式 .zip .gz .bz2 .tar.gz tar.bz2 zip zip格式的压缩文件和win ...
- 运行 jcontrol 报 libXext.so.6: cannot open shared object file 错误
需要安装额外库: yum install libXext.x86_64 yum install libXrender.x86_64 yum install libXtst.x86_64
- python字典添加元素和删除元素
1. 添加字典元素 方法一:直接添加,给定键值对 #pycharm aa = {'人才':60,'英语':'english','adress':'here'} print(aa) # {'人才': 6 ...
- AD19新功能之Gloss Selected(修线)
一.强大的修线功能 鼠标从右下往左上框选线,然后按 tab 键,选中需要修的走线 然后执行 “Route”栏下 “Gloss Selected”命令进行修线: 二.循环至推模式 AD19默认为推挤模式 ...