Actually, a combination of MattMc3's answer and FremenFreedom's answer should work.
Download SQL Express.
Then, declare the following stored procedure:
create procedure IsValidSQL (@sql varchar(max)) as
begin
begin try
set @sql = 'set parseonly on;'+@sql;
exec(@sql);
end try
begin catch
return(1);
end catch;
return(0);
end; -- IsValidSQL
You can test it with:
declare @retval int;
exec @retval = IsValidSQL 'select iif(val, 0, 1) from t';
select @retval
or with:
declare @retval int;
exec @retval = IsValidSQL 'select val from t';
select @retval
Note: this will catch the IIF() issue. It will not catch anything related to the table structures or column structures. You would need the schema for that and a slightly different approach ("select top 0 * from () t") woudl do it.
You might be able to do something with SQL Fiddle online. However, I would suggest having a local copy of the database.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…