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. (一)PlantUML 语法之时序图

    文章目录 前言 `-> -->` 信息传递 声明参与者的几个关键字 `as` 重命名参与者 `#` 添加颜色 `order` 定义参与者顺序 `""` 参与者名字 给自 ...

  2. 剑指offer27:按字典序打印出该字符串中字符的所有排列

    1 题目描述 输入一个字符串,按字典序打印出该字符串中字符的所有排列.例如输入字符串abc,则打印出由字符a,b,c所能排列出来的所有字符串abc,acb,bac,bca,cab和cba. 输入描述: ...

  3. Python调用API接口的几种方式

    Python调用API接口的几种方式 相信做过自动化运维的同学都用过API接口来完成某些动作.API是一套成熟系统所必需的接口,可以被其他系统或脚本来调用,这也是自动化运维的必修课. 本文主要介绍py ...

  4. TZOJ3133: 求对称点

    #include<stdio.h> int main() { double a,b,c,d,e,f,g,h,i; while(~scanf("%lf %lf %lf %lf %l ...

  5. 在uboot里面添加环境变量使用run来执行

    在uboot里面添加环境变量使用run来执行 本文链接:https://blog.csdn.net/u010979030/article/details/41038259 Author:杨正  Dat ...

  6. zabbix 数据库分表操作

    近期zabbix数据库占用的io高,在页面查看图形很慢,而且数据表已经很大,将采用把数据库的数据目录移到新的磁盘,将几个大表进行分表操作 一.数据迁移: 1.数据同步到新的磁盘上,先停止mysql(不 ...

  7. 起始路由改成分区(Areas)的RouteConfig.cs配置方法

    public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/ ...

  8. Queryable查询扩展

    /// <summary> /// 查询扩展 /// </summary> /// <typeparam name="T"></typep ...

  9. seo是什么

    SEO(Search Engine Optimization):汉译为搜索引擎优化.搜索引擎优化是一种利用搜索引擎的搜索规则来提高目前网站在有关搜索引擎内的自然排名的方式. SEO的目的是:为网站提供 ...

  10. BLE 广播格式定义

    低功耗蓝牙两类报文 : 广播报文 和 数据报文. 本文讨论广播报文数据段,不包括完整报文其他部分,比如前导,接入地址等 蓝牙设备通过广播表明自己的存在,等待被连接, 就好象一个人站在接口大喊“我要脱单 ...