標題:
[發問]
sql 語法 更新欄位太多如何串接
[打印本頁]
作者:
starry1314
時間:
2018-8-29 11:33
標題:
sql 語法 更新欄位太多如何串接
請問各位因我欄位有40個~目前是以以下方式去做串接
但做到第1X個之後就警告說串接過多了~
請問可以怎麼做改進呢?
Excel to Azure sql
Sql = "IF NOT EXISTS (SELECT 編號 from BOM WHERE 編號 ='" & sLastName & "') " & _
" INSERT into BOM (單號, 編號) " & _
" VALUES ('" & sFirstName & "', '" & sLastName & "')" & _
" else " & _
" update BOM set" & _
" 欄1= '" & s周期 & "'," & _
" 欄2 = '" & s特殊 & "'," & _
" 欄3 = '" & s日期 & "'," & _
" 欄4 = '" & s編號 & "'," & _
" 欄5 = '" & s餐別 & "'," & _
" 欄6 = '" & s類別 & "'," & _
" 欄7 = '" & s品名 & "'," & _
" 欄8 = '" & s數量 & "'," & _
" 欄9 = '" & s備註 & "'," & _
" 欄10 = '" & s異常 & "'," & _
" 欄11 = '" & s代號 & "'" & _
" where 編號 ='" & sLastName & "'"
複製代碼
作者:
faye59
時間:
2018-9-1 21:24
回復
1#
starry1314
很久沒寫程式了~SQL語法最近在複習中
印象中這樣就可以無限String~
試試看吧~
Sql = "IF NOT EXISTS (SELECT 編號 from BOM WHERE 編號 ='" & sLastName & "') "
Sql = Sql +" INSERT into BOM (單號, 編號) "
Sql = Sql +" VALUES ('" & sFirstName & "', '" & sLastName & "')"
Sql = Sql +" else "
Sql = Sql +" update BOM set"
Sql = Sql +" 欄1= '" & s周期 & "',"
Sql = Sql +" 欄2 = '" & s特殊 & "',"
Sql = Sql +" 欄3 = '" & s日期 & "',"
Sql = Sql +" 欄4 = '" & s編號 & "',"
Sql = Sql +" 欄5 = '" & s餐別 & "',"
Sql = Sql +" 欄6 = '" & s類別 & "',"
Sql = Sql +" 欄7 = '" & s品名 & "',"
Sql = Sql +" 欄8 = '" & s數量 & "',"
Sql = Sql +" 欄9 = '" & s備註 & "',"
Sql = Sql +" 欄10 = '" & s異常 & "',"
Sql = Sql +" 欄11 = '" & s代號 & "'"
Sql = Sql +" where 編號 ='" & sLastName & "'"
複製代碼
作者:
starry1314
時間:
2018-9-2 15:14
回復
2#
faye59
感謝指點~
頭腦太死 綁在一串字串內
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)