I ran your code against the Northwind database (assume that's where you were running it, as well)... Just to be sure, this is your code, isn't it (I added the ShowPlan)
SET SHOWPLAN_TEXT ON
go
DECLARE @CustomerID nchar(5)
SET @CustomerID = 'AROUT'
SELECT *
FROM Customers
WHERE (CustomerID = @CustomerID OR @CustomerID IS NULL)
SELECT *
FROM Customers
WHERE CustomerID = @CustomerID
When I run it, I get the same thing as when I show the graphical execution plan...
StmtText
------------------------------
SET STATISTICS PROFILE ON
(1 row(s) affected)
StmtText
-----------------------
SET SHOWPLAN_TEXT ON
(1 row(s) affected)
StmtText
--------------------------------------------------------------------------------------
DECLARE @CustomerID nchar(5)
SET @CustomerID = 'AROUT'
SELECT *
FROM Customers
WHERE (CustomerID = @CustomerID OR @CustomerID IS NULL)
(2 row(s) affected)
StmtText
-------------------------------------------------------------------------------------------------------------------------------------------------------
|--Clustered Index Scan(OBJECT[Northwind].[dbo].[Customers].[PK_Customers]), WHERE[Customers].[CustomerID]=[@CustomerID] OR [@CustomerID]=NULL))
(1 row(s) affected)
StmtText
----------------------------------------------------------------
SELECT *
FROM Customers
WHERE CustomerID = @CustomerID
(1 row(s) affected)
StmtText
------------------------------------------------------------------------------------------------------------------------------------------------
|--Clustered Index Seek(OBJECT[Northwind].[dbo].[Customers].[PK_Customers]), SEEK[Customers].[CustomerID]=[@CustomerID]) ORDERED FORWARD)
(1 row(s) affected)
StmtText
-----------------------------
SET STATISTICS PROFILE OFF
(1 row(s) affected)
No city index... no table scan... I'm thinking that something is wrong with your Northwind Customers table... it must be missing an index or PK or something...
--Jeff Moden
Change is inevitable... Change for the better is not.