Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

SELECT @@IDENTITY - sqljdbc driver Expand / Collapse
Posted Tuesday, September 15, 2009 5:19 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, September 17, 2009 8:34 AM
Points: 1, Visits: 8

We are porting a database from SQL Server 2000 to SQL Server 2008 and server is Weblogic server 8.1 SP6. Earlier for SQl 2000 we used jdriver and now we upgraded to sqljdbc 1.2 driver. We have problems with insert staments followed by an SELECT @@IDENTITY. SQLException has raised The statement did not return a result set.
We are using prepared statement.
Please give me suggestions to resolve this issue.

Thanks in advance
Post #788067
Posted Tuesday, September 15, 2009 6:53 AM



Group: General Forum Members
Last Login: Today @ 10:19 AM
Points: 7,507, Visits: 17,959
Switch to using the OUTPUT clause instead. It WILL be a single statement and won't have the vulnerabilities that @@identity has.

Insert MyTable(Mycolumns)
Output inserted.MyIdentity
select MyColumnValue

Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
Post #788104
Posted Thursday, September 17, 2009 4:05 AM



Group: General Forum Members
Last Login: Wednesday, May 25, 2016 1:11 PM
Points: 2,365, Visits: 1,865
select @@identity returns last inserted value of the current session. I think your prepared statement is run in one session and the select @@identity in another.

"Keep Trying"
Post #789511
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse