zoukankan      html  css  js  c++  java
  • SQL语句一点小心得

    在Sqlserver中 if 语句后面的语句加begin end 括起来

    问题:执行速度问题,在存储过程中没有加begin end 执行速度很慢,加了begin end执行速度加快

    ALTER PROCEDURE [dbo].[proc_Create_T_CAP]
    (@FileParth varchar(1000))
    AS
    begin
    --set @FileParth ='C:UsersAdministratorDesktop单病种excelQualityReport4400000043.xls'
    --set @FileName ='CAP$'
    if (@FileParth is null)
    begin
      print('请输入文件路径')
      return
      end
    end
    BEGIN
        if OBJECT_ID ('dbo.T_SD_CAP') is not null
        begin
        drop table dbo.T_SD_CAP


    问题2:查询条件where 中有 多个and 和多个or时 要把or条件用括号括起

    (select F_serial,F_sub_time,F_hospital_code,F_user_name,F_report_doc,
      F_report_time,'10',F_CAP_5_3, F_dcg_date_int, Datekey,P.FCYTYKH ,P.FPRN
       from HMI_DB.[dbo].[T_SD_CAP]  T,HMI_DB.dbo.TPATIENTVISIT P 
       where (F_CAP_3_1=1 or F_CAP_3_2=1)and T.[F_hspd_num]=p.FPRN 
        and SUBSTRING(CONVERT(varchar, T.F_dcg_date_int,120),0,11)=SUBSTRING(convert(varchar,p.FCYDATE,120),0,11) )   
     

  • 相关阅读:
    10.20stark组件已经完工
    webpack3到webpack4
    app埋点
    postman使用
    phantomjs
    nodejieba中文分词
    爬虫--cheerio
    mysql命令(三)
    mysql学习(二)
    mysql安装登录
  • 原文地址:https://www.cnblogs.com/a1991322/p/3286857.html
Copyright © 2011-2022 走看看