home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 18,238 of 19,505   
   Erland Sommarskog to omtechguy   
   Re: Use External value and use it from s   
   13 Apr 11 23:54:43   
   
   6ce8cec9   
   From: esquel@sommarskog.se   
      
   omtechguy (omtechguy@gmail.com) writes:   
   > On 2 ???, 10:55, Erland Sommarskog  wrote:   
   >> omtechguy (omtech...@gmail.com) writes:   
   >> Are these the actual queries, or are they just sketches of the real   
   >> views?   
   >>   
   >> If they are the real McCoy is there an index on TheValue? Is that a   
   >> clustered or a non-clustered index?   
   >>   
   >> With a hardcoded value, the optimizer has more exact information than   
   >> if you have something variable.   
   >>   
   >> I would try an inline-table function, and then use OPTION(RECOMPILE)   
   >> when I query the function.   
   >   
   > Can you please share an example?   
      
   CREATE FUNCTION myfunc(@myglobbval int) RETURNS TABLE AS   
   RETURN (SELECT * FROM MyTable where TheValue = @myglobval)   
   go   
   SELECT @myglobvalue = myglobalvalue   
   FROM   MySettingTable   
   SELECT * FROM myfunc(@myglobval)   
   OPTION (RECOMPILE)   
      
      
   --   
   Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se   
      
   Links for SQL Server Books Online:   
   SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx   
   SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca