Implement a function with below logic in an efficient way ...Pass @var1 and return @var2 ...How can it be done as it does table scan now ??
DECLARE @Var1 VARCHAR(10)
DECLARE @Var2 VARCHAR(100)
SELECT @var2= var2 FROM #test
WHERE var1 = @Var1
Thanks in advance
Try creating an index on your temp table before running that query - something like this:
create nonclustered index ix_test_var1 on #test(var1) include(var2)
Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this
If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.
Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.