//I am attempting to incorporate default variables into my SQL string to avoid syntax errors when loading my code. However, for some reason, adding the if statement is not producing any results.
{`var serversLength = Request.Form("servers").count;
var serversTemp = (serversLength) ? Request.Form("servers") : false;
var servers = [];
for (i = 1; i <= serversLength; i++) {
servers.push(serversTemp(i));
}
var options = "";
options += Request.Form("options");
%>
<%
var dateLength = Request.Form("date").count;
var dateTemp = (dateLength) ? Request.Form("date") : false;
var date= [];
for (i = 1; i <= dateLength; i++) {
date.push(dateTemp(i));
} %>
<%
var date2Length = Request.Form("date2").count;
var date2Temp = (date2Length) ? Request.Form("date2") : false;
var date2= [];
if (date2 === undefined){
date2="9/29/2015";
}
for (i = 1; i <= date2Length; i++) {
date2.push(date2Temp(i));
} %>
var SQL="SELECT LINKEDNAME, ERRNUM,CONVERT(CHAR(16),TSTAMP,21) AS TSTAMP, ERRDESC FROM MAIN.dbo.LINKEDSERVERFAILS " + ((serversLength) ? "WHERE LINKEDNAME IN ('" + servers.join("''") + "')" : "") + "AND TSTAMP BETWEEN" + ((dateLength) ? "('" + date.join("/ ") + "')" : "") + " AND " + ((date2Length) ? "('" + date2.join("/ ") + "')" : "") +""}