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 综合使用的例子的更多相关文章

  1. java当中JDBC当中请给出一个sql server的stored procedure例子

    3.sql server的stored procedure例子: import java.sql.*;public class StoredProc0 {public static void main ...

  2. SQL Server Service Broker 简单例子 (转)

    SQL Server Service Broker服务体系结构 消息类型 — 定义应用程序间交换的消息的名称.还可以选择是否验证消息.约定 — 指定给定会话中的消息方向和消息类型.队列 — 存储消息. ...

  3. sql server 的osql 使用例子

    一次性执行一个语句并输出到文件: osql -Usa -dSCGWYDJ2012 -P -S192.168.56.1 -Q "exit( SELECT top 1 * FROM A08)&q ...

  4. sql server 视图 的一个例子

    这是一个 有点复杂的查询.我现在 想把他封装 成 视图  其中  B.RecordID= 41 提供给 视图外查询. create view view_UserRecord as select Rec ...

  5. python 连接sql server

    linux 下pymssql模块的安装 所需压缩包:pymssql-2.1.0.tar.bz2freetds-patched.tar.gz 安装: tar -xvf pymssql-2.1.0.tar ...

  6. 第八篇 SQL Server安全数据加密

    本篇文章是SQL Server安全系列的第八篇,详细内容请参考原文. Relational databases are used in an amazing variety of applicatio ...

  7. 【译】第八篇 SQL Server安全数据加密

    本篇文章是SQL Server安全系列的第八篇,详细内容请参考原文. Relational databases are used in an amazing variety of applicatio ...

  8. sql server自定义排序

    方法一: 比如需要对SQL表中的字段NAME进行如下的排序:张三(Z)李四(L)王五(W)赵六(Z) 按照sql中的默认排序规则,根据字母顺序(a~z)排,结果为:李四  王五 赵六 张三 自定义排序 ...

  9. sql server函数(isnull,charindex,cast,自定义函数)

    SELECT charindex( CAST ( dbo.ufn_IsNullOrEmpty ('109722A3-622D-4FD4-A060-0287C933A89E', a.OUID) AS V ...

随机推荐

  1. (零)linux 学习 -- 从 shell 开始

    The Linux Command Line 读书笔记 - 部分内容来自 http://billie66.github.io/TLCL/book/chap02.html 文章目录 前言 什么是 she ...

  2. 华为模拟机试_C++题解

    华为模拟机试 [编程|100分] a+b 题目描述 计算a+b的和 每行包含两个整数a和b 对于每行输入对应输出一行a和b的和 输入 1 5 输出 6 自解 #include<iostream& ...

  3. pb笔记之数据窗口设置操作

    1 使DataWindow列只能追加不能修改如何使DataWindow中的数据只能追加新记录而不能修改,利用 Column 的 Protect 属性可以很方便的做到这一点,方法如下:将每一列的 Pro ...

  4. App客户端性能测试点总结

    一.内存 测试范围1. 空闲状态下的应用内存消耗情况2. 中等规格状态下的应用内存消耗情况3. 满规格状态下的应用内存消耗情况4. 应用内存峰值情况5. 应用内存泄露情况6. 应用是否常驻内存7. 压 ...

  5. Gogs + Drone 实现CI/CD(CD)

    前文已经实现CI部分,本文继续以Asp.Net Core实现CD部分. 创建gogs仓库 首先在gogs创建一个空项目drone-ci-demo,本地新建一个asp.net core项目,并且在与.c ...

  6. TR-FS00会计科目创建GL_ACCT_MASTER_SAVE

    https://blog.csdn.net/z_x_xing_/article/details/90514715 GL_ACCT_MASTER_SAVE   创建总账科目 前台事务代码:FS00 函数 ...

  7. Fortify漏洞之XML External Entity Injection(XML实体注入)

    继续对Fortify的漏洞进行总结,本篇主要针对  XML External Entity Injection(XML实体注入) 的漏洞进行总结,如下: 1.1.产生原因: XML External ...

  8. Source Insight用法

    快捷键 Symbol: Browse Project Symbols-:F7, Alt+G Relation View Relationship->For Functions->Pefer ...

  9. Innodb学习

    一.并发控制 为什么要进行并发控制? 因为并发的任务会对同一个临界资源进行操作,如果不进行并发控制,可能导致不一致,故必须进行并发控制. 如何进行并发控制? 1.锁. 2.数据多版本. 施工ing.. ...

  10. 【OF框架】使用IDbContextTransaction在框架中对多个实体进行事务操作

    准备 引用框架,按照规范建立数据库表及对应实体. 一.事务操作 关键代码 示例代码如下: //插入数据,使用数据库事务,不支持多连接. var dbContext = IoCHelper.Resolv ...