clear markdown compare help best fiddles feedback dbanow.uk a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 2335980 fiddles created (27484 in the last week).

CREATE TABLE dbo.Products ( ID integer NOT NULL UNIQUE CLUSTERED, [Name] varchar(10) NOT NULL PRIMARY KEY NONCLUSTERED, Code varchar(20) NOT NULL, SearchCode AS ISNULL( CONVERT(varchar(20), REPLACE( REPLACE(Code, '-', ''), '.', '') ), ''), INDEX [IX dbo.Products SearchCode (Name)] (SearchCode) INCLUDE ([Name]) );
 hidden batch(es)


INSERT dbo.Products (ID, [Name], Code) VALUES (1, 'One', '123.456.789-M'), (2, 'Two', '852.789456'), (3, 'Three', '1-123654.P');
3 rows affected
 hidden batch(es)


set statistics xml on; SELECT P.ID, P.[Name] FROM dbo.Products AS P WHERE P.SearchCode = '123456789M';
ID Name
1 One
Microsoft SQL Server 2005 XML Showplan
<ShowPlanXML xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan" Version="1.539" Build="15.0.4053.23"><BatchSequence><Batch><Statements><StmtSimple StatementText="SELECT [P].[ID],[P].[Name] FROM [dbo].[Products] [P] WHERE [P].[SearchCode]=@1" StatementId="1" StatementCompId="2" StatementType="SELECT" RetrievedFromCache="true" StatementSubTreeCost="0.0032831" StatementEstRows="1" SecurityPolicyApplied="false" StatementOptmLevel="TRIVIAL" QueryHash="0xAD47E9070D568D6F" QueryPlanHash="0x0EA21BBC43C62D41" CardinalityEstimationModelVersion="150"><StatementSetOptions QUOTED_IDENTIFIER="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" NUMERIC_ROUNDABORT="false"></StatementSetOptions><QueryPlan DegreeOfParallelism="0" NonParallelPlanReason="NoParallelPlansInDesktopOrExpressEdition" CachedPlanSize="24" CompileTime="0" CompileCPU="0" CompileMemory="176"><MemoryGrantInfo SerialRequiredMemory="0" SerialDesiredMemory="0" GrantedMemory="0" MaxUsedMemory="0"></MemoryGrantInfo><OptimizerHardwareDependentProperties EstimatedAvailableMemoryGrant="838808" EstimatedPagesCached="52425" EstimatedAvailableDegreeOfParallelism="1" MaxCompileMemory="3762840"></OptimizerHardwareDependentProperties><OptimizerStatsUsage><StatisticsInfo LastUpdate="2021-05-19T19:53:14.59" ModificationCount="0" SamplingPercent="100" Statistics="[IX dbo.Products SearchCode (Name)]" Table="[Products]" Schema="[dbo]" Database="[fiddle_650f63c6e0fe403ba2690aee9986633b]"></StatisticsInfo></OptimizerStatsUsage><TraceFlags IsCompileTime="1"><TraceFlag Value="460" Scope="Global"></TraceFlag><TraceFlag Value="8017" Scope="Global"></TraceFlag></TraceFlags><TraceFlags IsCompileTime="0"><TraceFlag Value="460" Scope="Global"></TraceFlag><TraceFlag Value="8017" Scope="Global"></TraceFlag></TraceFlags><QueryTimeStats ElapsedTime="0" CpuTime="0"></QueryTimeStats><RelOp NodeId="0" PhysicalOp="Index Seek" LogicalOp="Index Seek" EstimateRows="1" EstimatedRowsRead="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="20" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="3" Parallel="0" EstimateRebinds="0" EstimateRewinds="0" EstimatedExecutionMode="Row"><OutputList><ColumnReference Database="[fiddle_650f63c6e0fe403ba2690aee9986633b]" Schema="[dbo]" Table="[Products]" Alias="[P]" Column="ID"></ColumnReference><ColumnReference Database="[fiddle_650f63c6e0fe403ba2690aee9986633b]" Schema="[dbo]" Table="[Products]" Alias="[P]" Column="Name"></ColumnReference></OutputList><RunTimeInformation><RunTimeCountersPerThread Thread="0" ActualRows="1" Batches="0" ActualExecutionMode="Row" ActualElapsedms="0" ActualCPUms="0" ActualScans="1" ActualLogicalReads="2" ActualPhysicalReads="0" ActualReadAheads="0" ActualLobLogicalReads="0" ActualLobPhysicalReads="0" ActualLobReadAheads="0" ActualRowsRead="1" ActualEndOfScans="1" ActualExecutions="1"></RunTimeCountersPerThread></RunTimeInformation><IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" ForceSeek="0" ForceScan="0" NoExpandHint="0" Storage="RowStore"><DefinedValues><DefinedValue><ColumnReference Database="[fiddle_650f63c6e0fe403ba2690aee9986633b]" Schema="[dbo]" Table="[Products]" Alias="[P]" Column="ID"></ColumnReference></DefinedValue><DefinedValue><ColumnReference Database="[fiddle_650f63c6e0fe403ba2690aee9986633b]" Schema="[dbo]" Table="[Products]" Alias="[P]" Column="Name"></ColumnReference></DefinedValue></DefinedValues><Object Database="[fiddle_650f63c6e0fe403ba2690aee9986633b]" Schema="[dbo]" Table="[Products]" Index="[IX dbo.Products SearchCode (Name)]" Alias="[P]" IndexKind="NonClustered" Storage="RowStore"></Object><SeekPredicates><SeekPredicateNew><SeekKeys><Prefix ScanType="EQ"><RangeColumns><ColumnReference Database="[fiddle_650f63c6e0fe403ba2690aee9986633b]" Schema="[dbo]" Table="[Products]" Alias="[P]" Column="SearchCode" ComputedColumn="1"></ColumnReference></RangeColumns><RangeExpressions><ScalarOperator ScalarString="[@1]"><Identifier><ColumnReference Column="@1"></ColumnReference></Identifier></ScalarOperator></RangeExpressions></Prefix></SeekKeys></SeekPredicateNew></SeekPredicates></IndexScan></RelOp><ParameterList><ColumnReference Column="@1" ParameterDataType="varchar(8000)" ParameterCompiledValue="&apos;123456789M&apos;" ParameterRuntimeValue="&apos;123456789M&apos;"></ColumnReference></ParameterList></QueryPlan></StmtSimple></Statements></Batch></BatchSequence></ShowPlanXML>
 hidden batch(es)