Blog Stats
  • Posts - 14
  • Articles - 0
  • Comments - 14
  • Trackbacks - 0

 

Subquery returned more than 1 value

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

As the error message suggests , this normally occurs when you are assigning a T-SQL variable a value within sql query and the query is returning more that one rows e.g.
Declare @var1 nvarchar(50)
' select @var1=name from table1'

Putting 'top 1' can resolve the problemĀ  in many cases ( do check the business logic aspects):

' select top 1 @var1=name from table1'

Feedback

No comments posted yet.


Post a comment





 

 

 

 

Copyright © faizanahmad