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 ...
随机推荐
- FireDAC 如何按整型(Byte)读取 MySQL TinyInt(1) 类型字段?
最近使用 MySQL 发现 FireDAC 中查询 TinyInt(1) 字段结果是 Boolean 类型,这并不是我想要的结果,而TinyInt(1)的范围是-128-127之间,如何按整型读取呢? ...
- 二十四、V4L2框架主要结构体分析和虚拟摄像头驱动编写
一.V4L2框架主要结构体分析 V4L2(video for linux version 2),是内核中视频设备的驱动框架,为上层访问视频设备提供统一接口. V4L2整体框架如下图: 图中主要包括两层 ...
- Shiro授权及注解式开发
目的: shiro授权 shiro注解式开发 Shiro授权 首先设计shiro权限表: 从图中我们也清晰的看出五张表之间的关系 ShiroUserMapper Set<String> g ...
- 将springboot项目移到内网出现的问题!
报找不到Jay包错误,在pom.xml文件中加这段 <repositories> <repository> <id>central</id> <u ...
- 用chattr命令防止系统中某个关键文件被修改
用chattr命令防止系统中某个关键文件被修改:# chattr +i /etc/resolv.conf
- C++ 去掉字符串的首尾空格和全部空格
#include <iostream>#include <string>using namespace std; //去掉收尾空格string& ClearHeadTa ...
- POJ 3233-Matrix Power Series( S = A + A^2 + A^3 + … + A^k 矩阵快速幂取模)
Matrix Power Series Time Limit: 3000MS Memory Limit: 131072K Total Submissions: 20309 Accepted: ...
- Tomcat安装及环境配置
欢迎任何形式的转载,但请务必注明出处. 本章内容 安装 环境变量入口 三个系统变量配置 测试安装配置是否成功 安装之前请安装jdk并进行环境配置(点击进入jdk教程) 一.安装 点击进入官网下载 二. ...
- Java 之 TCP 通信程序
一.概述 TCP 通信能实现两台计算机之间的数据交互,通信的两端,要严格区分为客户端(Client)与服务端(Server). 两端通信时步骤: 1.服务端程序,需要事先启动,等待客户端的连接: 2. ...
- 读取普通java web项目下的WEB-INF目录下的配置文件(application.xml,xx.properties等配置文件)
一.在Java web工程WEB-INF下创建weixin.properties属性文件 weixin.properties属性文件里内容如下: 二.创建PropertiesUtils.java测试类 ...