Table of Contents
SQL Server Error: 116
Severity: 15
Event Logged or not: No
Description:
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
Severity 15 Description:
Indicates syntax errors in the Transact-SQL command.
Example:
SELECT [ID], [Date], [Description], [Count] FROM [dbo].[Order] WHERE [ID] NOT IN (SELECT [ID], [NumberofStock] FROM [dbo].[Stock]) Msg 116, Level 16, State 1, Line 4 Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
This error usually occurs when a sub-query is used in conjunction with the IN or NOT IN logical operator. The IN logical operator checks to see if a given value matches any value in a subquery or a list. The NOT IN logical operator is used to reject a subquery or list.
In the case of the IN operator, the SELECT statement can be used to return all ID records that have corresponding records for Stock in Stock Table.
Because only unique ID records are required in the output, the DISTINCT clause can be included. If there are multiple ID records for a given ID record, the ID be returned multiple times in the output which is the need for the use of the DISTINCT clause.
The EXISTS operator can also be used to rewrite the SELECT statement that returns ID records that have corresponding ID records for Stock in Stock Table.
In the case of the NOT IN operator to be used, the SELECT statement can be used to return all ID records that do not have corresponding ID records for Stock in Stock Table
SQL Server Error: 116
Severity: 15
Event Logged or not: No
Description:
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
Make sure only one column is returned in “IN” Statement use and try rewrite query correctly.
Learn about SQL Server detecting logical consistency based issues and how to resolve them.
Learn about SQL Server error 1222 and how to resolve the lock request time out…
Discover the new features of Microsoft SQL Server 2022 and how they compare to previous…
SQL Server Error 1222 lock request time out period exceeded Lock request time out…
SQL Server Error : 427, Severity: 20. Could not load the definition for constraint ID…
SQL Server Error : 204, Severity: 20. Normalization error in node %ls.
This website uses cookies.