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. go http简单的表单处理

    //表单处理 package main import (     "net/http"     "io"     "fmt"     &qu ...

  2. Spring Boot的配置文件-yml文件的集合配置方式

    yml集合数据的表示方式: 这种方式是配置普通的字符串—— 如果集合中装的是对象,就这么配置—— 行内配置方式—— map的配置方式——

  3. Arm-Linux 移植 FFMPEG库 + x264

      背景: ffmpeg 中带有264的解码,没有编码,需要添加x264.libx264是一个自由的H.264编码库,是x264项目的一部分,使用广泛,ffmpeg的H.264实现就是用的libx26 ...

  4. vue 写一个炫酷的轮播图

    效果如上图: 原理: 1.利用css 的 transform 和一些其他的属性,先选五张将图片位置拍列好,剩余的隐藏 2.利用 js 动态切换类名,达到切换效果 css代码如下 .swiper-cer ...

  5. Python 在气象上的应用

    Python 在气象上的应用 grug350关注 0.7892019.03.15 23:19:31字数 913阅读 1,024 为什么选择python 免费和开源,没有商业许可限制anaconda p ...

  6. VMware Workstation Pro 15 序列号

    VMware Workstation Pro 15 序列号: GA70H-8TYE2-H886P-04YZC-YVA84 YG5H2-ANZ0H-M8ERY-TXZZZ-YKRV8 UG5J2-0ME ...

  7. hdu 1075 map的使用 字符串截取的常用手段 以及string getline 使用起来的注意事项

    首先说字符串的截取套路吧 用坐标一个一个的输入 用遍历的方式逐个去检查字符串中的字符是否为符合的情况 如果是的话 把该字符放入截取string 中 让后坐标前移 如果不是的话 截取结束 坐标初始化 然 ...

  8. 【转载】使用Class.getResource和ClassLoader.getResource方法获取文件路径

    自从转投Java阵营后,一直发下Java程序的路径读取异常麻烦,因此查阅了比较多的版本内容,整合了一份自己的学习笔记.主要使用Class及通过ClassLoader来动态获取文件路径. 查阅链接如下: ...

  9. Identityserver4证书

      dotnet应用用IdentityServer4做了登陆的功能,本地运行没有问题,部署到服务器上面就出现上面的问题,打开服务器的日志记录开关,获取到下面的异常信息.原来是     通过分析日志信息 ...

  10. 使用SAP Cloud Platform Leonardo机器学习提取图片的特征向量

    选中一个需要进行测试的Leonardo机器学习服务,点击Configure Environments: 因为我不想使用sandbox环境,所以我选择了eu10这个region: 维护clientid和 ...