<% Response.ContentType = "text/plain" Dim objConn, rs, sql, appid, appName appid = 8 appName = "eMX" Set objConn = GetDatabaseConnection() sql = "SELECT linkid, LEFT(shortdescription, 60) as description, clicks, appid, " & _ "CASE WHEN appid = " & appid & " THEN 1 ELSE 0 END as direct_link " & _ "FROM knowledgebase " & _ "WHERE isactive = 1 " & _ "AND (appid = " & appid & " " & _ " OR keywords LIKE '%" & Replace(appName, "'", "''") & "%' " & _ " OR shortdescription LIKE '%" & Replace(appName, "'", "''") & "%') " & _ "ORDER BY direct_link DESC, clicks DESC, shortdescription ASC" Response.Write("SQL: " & sql & vbCrLf & vbCrLf) Set rs = objConn.Execute(sql) While Not rs.EOF Response.Write("ID: " & rs("linkid") & " | ") Response.Write("Direct: " & rs("direct_link") & " | ") Response.Write("Clicks: " & rs("clicks") & " | ") Response.Write("Desc: " & rs("description") & vbCrLf) rs.MoveNext Wend rs.Close objConn.Close %>