Quantcast
Channel: Help Optimizing TSQL Query
Viewing all articles
Browse latest Browse all 8

Help Optimizing TSQL Query

$
0
0

Why aer you joining the table to itself?

If you can avoid INNER JOIN and just use CTE, that's the better way of doing it

is that because you need Row_Number() = 2?

 

If yes, you don't need to do inner join

 

use CTE without JOIN

;with

 cte as



(

 SELECTROW_NUMBER

() OVER

 (ORDERBY

 ParentLoginID ASC

) 
  AS

 RowNumber,
  [ParentLoginID],
  [LoginName],
  [LoginPwd],
  [LoginSSN],
  [MultiFactorQuestion],
  [MultiFactorAnswer] 
  FROM

 [MMA_TestCases].[dbo].[v_CompleteLogin]

)
select

 
 [ParentLoginID],
  [LoginName],
  [LoginPwd],
  [LoginSSN],
  [MultiFactorQuestion],
  [MultiFactorAnswer] 
from


cte where

 rownumber = @yourVariable


Thanks, Cool Mind -- If you find my answer helpful, please mark it as Answer.

Viewing all articles
Browse latest Browse all 8

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>