i get the SQL Server Error 11509 when preparing a SQL Statement with two different SELECT instructions.
How can i avoid this error?
For demonstration i prepared a simple example.
Code: Select all
var
  q: TMSQuery;
begin
  q := TMSQuery.Create(nil);
  try
    q.Connection := StdManDataBase;
    q.SQL.BeginUpdate();
    q.SQL.Add('IF 1 = 1');
    q.SQL.Add('SELECT 1, 2');
    q.SQL.Add('ELSE');
    q.SQL.Add('SELECT 1');
    q.SQL.EndUpdate();
    q.Prepare; // SQL Server Error 11509
  finally
    q.Free;
  end;