php - MSSQL: Must declare the scalar variable @rownum -


one of queries ranking game.

the query below , error sql server management studio shows is: "must declare scalar variable @rownum"

what wrong it?

thanks lot!

 $sql1_1     = "set @rownum := 0";    $sql2_2       =   "select * (                       select @rownum := @rownum + 1 rank, totalpoints, useridfb, game2points                       theuser order game2points desc                       ) result useridfb=1234";            mssql_query($sql1_1);          $result = mssql_query($sql2_2);          $row = mssql_fetch_array($result);         $therank = $row['rank']; 

you using mysql syntax in sql server.

use row_number() function reproduce current logic.

select *   (select row_number() on (order game2points desc) [rank],                totalpoints,                useridfb,                game2points           theuser) result  useridfb = 1234   

or might want investigate rank depending on how want ties treated.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -