2010-08-17 161 views
0

可能重複:
please correct me with the sql querySQL查詢錯誤

給錯誤下面Ÿ提到的,所以請糾正我對這個

消息137,級別15,狀態2,行1 必須聲明標量變量「@courseId」。

@"SELECT * FROM [tbl_students] WHERE [email protected] AND branch_id IN("[email protected]") 
       AND (@passoutYear is null OR passing_year>[email protected]) 
       AND (@currentBacklog is null OR current_backlog<[email protected]) 
AND [email protected] AND (@eGap is null OR gapin_education<[email protected]) 
AND (@firstYrPercent is null OR first_year_percent>[email protected] 
AND (@secondYrpercent is null OR second_year_percent>[email protected]) 
AND (@thirdYrPercent is null OR third_year_percent>[email protected]) 
AND (@finalYrpercent is null OR final_year_percent>[email protected]) 
AND (@currentDegreePercentage is null OR current_degree_percent>[email protected]) 
AND (@highSchoolPercentage is null OR highschool_percentage>[email protected]) 
AND (@higherSchoolPercentage is null OR ssc_percentage>[email protected]) 
AND (@graduationPercent is null OR graduation_percentage>[email protected]) 
AND (@diplomaPercentage is null OR diploma_percentage>[email protected]) 
AND (@noOfAtkt is null OR number_of_ATKT<[email protected]) 
AND (@date is null OR DOB>[email protected])" 
+2

請編輯您的[原來的問題(HTTP:/ /stackoverflow.com/questions/3499381/please-correct-me-with-the-sql-query)而不是創建一個新的。 – BoltClock 2010-08-17 05:39:15

+0

@BoltClock:原始問題(3499381)似乎是由於在查詢字符串開始之前省略了@符號而導致的錯誤 - 請參閱Helgi Hrafn Gunnarsson的回答,該回答被接受爲正確。這個問題涉及SQL本身的錯誤;因此,我認爲把它作爲原始問題的重複來解決是錯誤的。我不知道該怎麼做,但我建議重新打開這個問題。 – 2010-08-19 13:13:45

+0

請你回答一些已經留給這個問題的答案。 – 2010-08-19 13:14:53

回答

0

這只是意味着你忘了你的命令創建@courseIdSqlParameter值。

0

您可以:

  • 未聲明的SQL查詢
  • 內您的變量@courseId不聲明參數,存儲過程