If Exists Update Else Insert with VB.net (sql parameterised query)

前端 未结 3 1111
灰色年华
灰色年华 2021-01-22 15:55

I\'m hoping to use the following update\\insert method to speed up my application insert\\updates:

UPDATE [Application_Type_Table] 
SET ApplicationType=\'Test Va         


        
3条回答
  •  孤城傲影
    2021-01-22 16:29

    sqlCommand.CommandText = "IF NOT EXISTS (SELECT 1 FROM  [Application_Type_Table] WHERE "_
    "ID='1') BEGIN INSERT INTO " _
    "[Application_Type_Table] VALUES ('Test Value') END ELSE BEGIN UPDATE [Application_Type_Table]"_
    "SET ApplicationType='Test Value'"_
    "WHERE ID='1' END"
    

提交回复
热议问题