From 7f02ee768cc193766ed0147ceffd83b072fecde1 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Wed, 16 Sep 2015 05:49:14 +0000 Subject: [PATCH] Use db.func instead of schema.func when schema is empty, on retrieving MSSQL routine structure. See http://www.heidisql.com/forum.php?t=19350#p19360 --- source/dbconnection.pas | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/source/dbconnection.pas b/source/dbconnection.pas index 2ae798c3..bb75eca3 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -2806,7 +2806,10 @@ begin ngMSSQL: begin // Tested on MS SQL 8.0 and 11.0 // See http://www.heidisql.com/forum.php?t=12495 - Rows := GetCol('EXEC sp_helptext '+EscapeString(Schema+'.'+Name)); + if not Schema.IsEmpty then + Rows := GetCol('EXEC sp_helptext '+EscapeString(Schema+'.'+Name)) + else + Rows := GetCol('EXEC sp_helptext '+EscapeString(Database+'.'+Name)); // Do not use Rows.Text, as the rows already include a trailing linefeed Result := implodestr('', Rows); Rows.Free; @@ -2855,7 +2858,10 @@ begin case Parameters.NetTypeGroup of ngMSSQL: begin // See comments above - Rows := GetCol('EXEC sp_helptext '+EscapeString(Schema+'.'+Name)); + if not Schema.IsEmpty then + Rows := GetCol('EXEC sp_helptext '+EscapeString(Schema+'.'+Name)) + else + Rows := GetCol('EXEC sp_helptext '+EscapeString(Database+'.'+Name)); Result := implodestr('', Rows); Rows.Free; end; @@ -2889,8 +2895,12 @@ begin Queries.Add('SHOW CREATE '+UpperCase(Obj.ObjType)+' '+QuoteIdent(Obj.Database)+'.'+QuoteIdent(Obj.Name)); end; ngMSSQL: begin - if Obj.NodeType in [lntFunction, lntProcedure] then - Queries.Add('EXEC sp_helptext '+EscapeString(Obj.Schema+'.'+Obj.Name)); + if Obj.NodeType in [lntFunction, lntProcedure] then begin + if not Obj.Schema.IsEmpty then + Queries.Add('EXEC sp_helptext '+EscapeString(Obj.Schema+'.'+Obj.Name)) + else + Queries.Add('EXEC sp_helptext '+EscapeString(Obj.Database+'.'+Obj.Name)) + end; end; end; end;