I run this and it always falls thru on the else...but in the alert, it returns 0. Why is it not working for me?
//TableExists("mssql://" + ServerName.getText() + ":1434/" + DataBaseName.getText(),
var strSQL = "IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES ";
strSQL += "WHERE TABLE_NAME = N'" + TableName.getText() + "' ";
strSQL += "AND TABLE_TYPE = 'BASE TABLE') ";
strSQL += "BEGIN SELECT '1' as TblName END ";
strSQL += "ELSE ";
strSQL += "BEGIN SELECT '0' as TblName END";
var rsTbl = db2.execute(strSQL);
if (rsTbl.TblName = '0')
{
alert("Table '" + TableName.getText() + "' does not exist in " + ServerName.getText() + "/" + DataBaseName.getText());
alert(rsTbl.TblName);
alert(strSQL);
return;
}
else
{
alert("Table Exists");
alert(rsTbl.TblName);
alert(strSQL);
return;
}