clear markdown compare help donate or buy diddy dollings comments/suggestions/bugs a leap of faith? bible365
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. 630111 fiddles created (11373 in the last week).

declare @TEMP table(asWord nvarchar(max), asNumber int) insert into @TEMP (asWord, asNumber) values ( 'one', 1 ), ( 'two', 2 ) DECLARE @test nvarchar(max) SET @test = 'one' select * from @TEMP where asWord = @test OPTION (OPTIMIZE FOR(@test = N'one'))
Msg 4132 Level 16 State 1 Line 14 The value specified for the variable "@test" in the OPTIMIZE FOR clause could not be implicitly converted to that variable's type.
 hidden batch(es)


declare @TEMP table(asWord nvarchar(max), asNumber int) insert into @TEMP (asWord, asNumber) values ( 'one', 1 ), ( 'two', 2 ) DECLARE @test nvarchar(3) SET @test = 'one' select * from @TEMP where asWord = @test OPTION (OPTIMIZE FOR(@test = N'one'))
asWord asNumber
one 1
 hidden batch(es)


declare @TEMP table(asWord nvarchar(max), asNumber int) insert into @TEMP (asWord, asNumber) values ( 'one', 1 ), ( 'two', 2 ) DECLARE @test nvarchar(255) SET @test = 'one' DECLARE @OPTIMIZEVALUE nvarchar(max) = 'one' select * from @TEMP where asWord = @test OPTION (OPTIMIZE FOR(@test = @OPTIMIZEVALUE))
Msg 320 Level 15 State 1 Line 18 The compile-time variable value for '@test' in the OPTIMIZE FOR clause must be a literal.
 hidden batch(es)


declare @TEMP table(asWord nvarchar(max), asNumber int) insert into @TEMP (asWord, asNumber) values ( 'one', 1 ), ( 'two', 2 ) DECLARE @test nvarchar(max) SET @test = 'one' select * from @TEMP where asWord = @test OPTION (OPTIMIZE FOR(@test = N'one ' ))
asWord asNumber
one 1
 hidden batch(es)