SQL中if语句的用法示例

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

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

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

 

 

 

 

【编辑推荐】

巧用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:49:02

SQL嵌套SELECT

2010-11-11 11:13:54

SQL Server

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语句

2010-05-11 10:12:50

mysql数据库sql

2022-05-19 23:40:34

SQL语句引号

2022-03-23 14:04:32

SQL字符串数据类型

2023-11-15 20:24:54

数据库SQLGo语言

2010-09-08 15:42:46

SQL指令UNION

2010-09-10 15:04:41

SQLDATENAME函数

2021-08-16 08:12:04

SQLMerge用法

2010-11-12 13:08:36

动态sql语句

2010-09-17 16:53:14

SQL中CREATE

2010-09-07 11:53:00

SQL语句
点赞
收藏

51CTO技术栈公众号