注册/登录

SQL中if语句的用法示例

数据库 SQL Server
if语句如何使用是SQL数据库新手都需要掌握的,下面就以实例的形式为您演示SQL中if语句的用法,供您参考,希望对你有所启迪。

SQL 中if语句是最常见也是最常用的SQL语句之一,下面就将为您举例说明SQL中if语句的用法,希望对您学习SQL中if语句的使用能够有些许帮助。

  1. _sql = " if not exists (select * from ProDesignSheet5 where Sheet5ID = '" + this.Sheet5id + "') "  
  2.               + " insert into ProDesignSheet5 values('" + this.Sheet5id  
  3.               + "','" + this.Consplacepbfee.ToString()  
  4.               + "','" + this.Searchtestfee.ToString()  
  5.               + "','" + this.Ccdesignfee.ToString()  
  6.               + "','" + this.Propreparefee.ToString()  
  7.               + "','" + this.Elecfee.ToString()  
  8.               + "','" + this.Workerdqfee.ToString()  
  9.               + "','" + this.Cjzpgdqfee.ToString()  
  10.               + "','" + this.Dxsgjxdqfee.ToString()  
  11.               + "','" + this.Debzglfee.ToString()  
  12.               + "','" + this.Jsqtzdkrate.ToString()  
  13.               + "','" + this.Gczljdfee.ToString()  
  14.               + "','" + this.Yuntufee.ToString()  
  15.               + "','" + this.Jfgzjgzfee.ToString()  
  16.               + "','" + this.Wsdyrfee.ToString()  
  17.               + "','" + this.Whclfee.ToString()  
  18.               + "','" + this.Bgyffee.ToString()  
  19.               + "','" + this.Yytfee.ToString()  
  20.               + "','" + this.Hlhtfee.ToString()  
  21.               + "','" + this.Jfxtfee.ToString()  
  22.               + "','" + this.Ybgjfee.ToString()  
  23.               + "','" + this.Gxzfzfee.ToString()  
  24.               + "','" + this.Lyglfee.ToString()  
  25.               + "','" + this.Jfzjfee.ToString()  
  26.               + "','" + this.Gdzjfee.ToString()  
  27.               + "','" + this.Gdlxlzjfee.ToString()  
  28.               + "','" + this.Workteamfee.ToString()  
  29.               + "','" + this.Condeptfee.ToString()  
  30.               + "','" + this.Tower.ToString()  
  31.               + "','" + this.Servicefee.ToString()  
  32.               + "','" + this.Checkfee.ToString()  
  33.               + "','" + this.Other.ToString()  
  34.               + "','" + this.ItemNum.ToString()  
  35.               + "','" + this.ItemName.ToString()  
  36.               + "','" + this.PassId.ToString()  
  37.               + "')"  
  38.               + " else update ProDesignSheet5 set Consplacepbfee='" + this.Consplacepbfee.ToString()  
  39.               + "',Searchtestfee='" + this.Searchtestfee.ToString()  
  40.               + "',Ccdesignfee='" + this.Ccdesignfee.ToString()  
  41.               + "',Propreparefee='" + this.Propreparefee.ToString()  
  42.               + "',Elecfee='" + this.Elecfee.ToString()  
  43.               + "',Workerdqfee='" + this.Workerdqfee.ToString()  
  44.               + "',Cjzpgdqfee='" + this.Cjzpgdqfee.ToString()  
  45.               + "',Dxsgjxdqfee='" + this.Dxsgjxdqfee.ToString()  
  46.               + "',Debzglfee='" + this.Debzglfee.ToString()  
  47.               + "',Jsqtzdkrate='" + this.Jsqtzdkrate.ToString()  
  48.               + "',Gczljdfee='" + this.Gczljdfee.ToString()  
  49.               + "',Yuntufee='" + this.Yuntufee.ToString()  
  50.               + "',Jfgzjgzfee='" + this.Jfgzjgzfee.ToString()  
  51.               + "',Wsdyrfee='" + this.Wsdyrfee.ToString()  
  52.               + "',Whclfee='" + this.Whclfee.ToString()  
  53.               + "',Bgyffee='" + this.Bgyffee.ToString()  
  54.               + "',Yytfee='" + this.Yytfee.ToString()  
  55.               + "',Hlhtfee='" + this.Hlhtfee.ToString()  
  56.               + "',Jfxtfee='" + this.Jfxtfee.ToString()  
  57.               + "',Ybgjfee='" + this.Ybgjfee.ToString()  
  58.               + "',Gxzfzfee='" + this.Gxzfzfee.ToString()  
  59.               + "',Lyglfee='" + this.Lyglfee.ToString()  
  60.               + "',Jfzjfee='" + this.Jfzjfee.ToString()  
  61.               + "',Gdzjfee='" + this.Gdzjfee.ToString()  
  62.               + "',Gdlxlzjfee='" + this.Gdlxlzjfee.ToString()  
  63.               + "',Workteamfee='" + this.Workteamfee.ToString()  
  64.               + "',Condeptfee='" + this.Condeptfee.ToString()  
  65.               + "',Tower='" + this.Tower.ToString()  
  66.               + "',Servicefee='" + this.Servicefee.ToString()  
  67.               + "',Checkfee='" + this.Checkfee.ToString()  
  68.               + "',Other='" + this.Other.ToString()  
  69.               //+ "',ItemNum='" + this.ItemNum.ToString()  
  70.               //+ "',ItemName='" + this.ItemName.ToString()  
  71.               //+ "',PassId='" + this.PassId.ToString()  
  72.               + "' where Sheet5id ='" + this.Sheet5id + "'";  
责任编辑:段燃 互联网
点赞
收藏