Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

SQLServerException: Incorrect syntax near / SQLServerException: Must declare the scalar variable

 
Rico Strydom
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

In my Java code I am getting an Sql Exception : .
When I remove all the U's from my statement then I am getting

This is my stored proc.



Can someone please help?
 
Dave Tolls
Ranch Hand
Posts: 2369
25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you doing an EXEC in there?
Why not simply call the UPDATE directly?
 
Rico Strydom
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is a difference?
 
Dave Tolls
Ranch Hand
Posts: 2369
25
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, yes.
The EXEC is for interpreting and executing a string.
T-SQL can run queries directly.

It's the use of EXEC that's causing you your problem.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!