Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

by Nathan 29. March 2009 08:29

I have come across this error when using a Indentity In a stored procedure.

In a stored procedure you need to define the scope indentity in a variable before you can use it in a select statement

So instead of

SELECT * FROM table WHERE id = SCOPE_IDENTITY()

You need to use 

 

SET @var = SCOPE_IDENTITY();

SELECT * FROM table WHERE id = @var

 

 @@IDENTITY  will return the last indentity across the whole database whilst SCOPE_IDENTITY() will return only the indentity related to the scope of the operation

Tags:

SQL

Comments

8/15/2009 2:35:01 AM #

Lassale Watches Seikos Top

Do you earn decent money from this blog or are you doing it just for fun?

Lassale Watches Seikos Top United States

8/17/2009 1:00:45 AM #

Timberland Qt8161101 Outdoor Performance

Do you accept guest posts? I would love to write couple articles here.

Timberland Qt8161101 Outdoor Performance United States

8/18/2009 10:27:02 PM #

Activa Womens Elegance Two

Would you like to post a guest post on my blog?

Activa Womens Elegance Two United States

8/27/2009 11:28:45 AM #

Baume Mercier Classima

Would you like to post a guest post on my blog?

Baume Mercier Classima United States

8/28/2009 7:13:34 AM #

bad credit loans

Hi, I can�t understand how to add your site in my rss reader. Can you Help me, please Smile

bad credit loans United States

12/26/2009 5:22:29 AM #

Lydia

I like how you write.Are you interesting in a part time writer job?

Lydia United States

12/27/2009 9:54:13 AM #

Martinez

You had great positive ideas there. I did a search on the issue and found nearly all peoples will agree with your blog.

Martinez United States

1/3/2010 6:16:50 AM #

Axel

Wonderful illustrated information. I thank you about that. No doubt it will be very useful for my future projects. Would like to see some other posts on the same subject!

Axel United States

1/6/2010 5:07:48 AM #

Wilber Urik

Hi. Pretty cool blog. I'm kind of new at this. Is this your first blog? My company is planning a similar website. I'll pass this blog on. Will you be selling advertising? I think the method is pay per view. Keep up the good job!

Wilber Urik United States

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.6.0.0
Theme by Mads Kristensen