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 + "'";  

 

 

 

 

【编辑推荐】

巧用SQL server临时表

速学如何定义SQL存储过程

sql server表改为dbo的方法

教您sql server表结构的修改方法

上亿的sql server表进行join的问题

责任编辑:段燃 来源: 互联网
相关推荐

2009-01-14 09:28:12

OracleSQL10g

2011-03-07 13:27:13

SQLCase

2010-09-08 16:17:37

SQL循环语句

2010-09-25 14:59:54

SQL语句

2010-11-11 11:13:54

SQL Server

2010-11-11 11:49:02

SQL嵌套SELECT

2010-09-07 13:41:50

SQL语句

2010-07-26 16:39:57

SQL Server

2010-10-08 15:54:34

mysql中case

2010-09-06 09:11:24

SQLUPDATE语句

2023-11-15 20:24:54

数据库SQLGo语言

2010-05-11 10:12:50

mysql数据库sql

2022-03-23 14:04:32

SQL字符串数据类型

2022-05-19 23:40:34

SQL语句引号

2010-09-08 15:42:46

SQL指令UNION

2021-08-16 08:12:04

SQLMerge用法

2010-09-10 15:04:41

SQLDATENAME函数

2010-11-12 13:08:36

动态sql语句

2010-09-17 16:53:14

SQL中CREATE

2010-09-07 11:53:00

SQL语句
点赞
收藏

51CTO技术栈公众号