SELECT *
FROM Customers
WHERE EXISTS (SELECT OrderID INTERSECT SELECT @OrderID)
Will do this efficiently.
See Undocumented Query Plans: Equality Comparisons for more about this.
More Related Contents:
- T-SQL: Export to new Excel file
- SQL MERGE statement to update data
- How to get the last record per group in SQL
- T-SQL substring – separating first and last name
- How to get week number of the month from the date in sql server 2008
- T-SQL strip all non-alpha and non-numeric characters
- Recursive Child/Parent queries in T/SQL
- I dont know sql syntax for my table [closed]
- CROSS JOIN vs INNER JOIN in SQL
- How to check if a column exists in a SQL Server table
- Multiple INSERT statements vs. single INSERT with multiple VALUES
- Generate Dates between date ranges
- How do you view ALL text from an ntext or nvarchar(max) in SSMS?
- How to print VARCHAR(MAX) using Print Statement?
- Common Table Expression, why semicolon?
- T-SQL split string based on delimiter
- INSERT INTO vs SELECT INTO
- SQL Recursive CTE: Finding objects linked by property
- Why is SQL Server 2008 Management Studio Intellisense not working?
- Reporting Services permissions on SQL Server R2 SSRS
- Convert decimal time to hours and minutes
- Do clustered indexes have to be unique?
- How do I prevent a database trigger from recursing?
- How to implement polymorphic associations in an existing database
- What is the default transaction isolation level for SQL Server with ADO.NET?
- How to combine results of two queries into a single dataset
- Executing SQL Server Agent Job from a stored procedure and returning job result
- How Can I Detect and Bound Changes Between Row Values in a SQL Table?
- COALESCE Function in TSQL
- Stored procedure hangs seemingly without explanation