Board index » delphi » How to read @@ServerName from MSSQL 7?

How to read @@ServerName from MSSQL 7?

Hi,

how can one read @@-variables (for example: @@ServerName)
from MSSQL (using SQL7 and D5 Enterprise)?

I tried TQuery with "SELECT @@ServerName" but got no
results. The same SQL-Statement in MSSQL-Enterprise-Manager
works fine.

TIA
Frank

 

Re:How to read @@ServerName from MSSQL 7?


Hi Frank,

Works fine with me! Maybe inserting an AS statement helps:

  SQL.Add('SELECT @@ServerName AS MyServerName');
  Active := true;
  Showmessage(FieldByName('MyServerName').AsString);

Greets, Joost

Quote
"Frank Linde" <li...@lindedaten.de> wrote in message

news:3AC06821.75BE2D40@lindedaten.de...
Quote
> Hi,

> how can one read @@-variables (for example: @@ServerName)
> from MSSQL (using SQL7 and D5 Enterprise)?

> I tried TQuery with "SELECT @@ServerName" but got no
> results. The same SQL-Statement in MSSQL-Enterprise-Manager
> works fine.

> TIA
> Frank

Re:How to read @@ServerName from MSSQL 7?


Try

SELECT CONVERT(VARCHAR(30),@@SERVERNAME) AS SERVER_NAME

I believe that SQL server 7 returns @@servername as unicode which the BDE
does not support - hence the conversion to a type the BDE does support.

HTH.

John.

Re:How to read @@ServerName from MSSQL 7?


Hi Joost,

thanks, that was half the battle! As John suggested, MSSQL
needs an additional conversion.

Regards
Frank

Joost van Rijswijk schrieb:

Quote

> Hi Frank,

> Works fine with me! Maybe inserting an AS statement helps:

>   SQL.Add('SELECT @@ServerName AS MyServerName');
>   Active := true;
>   Showmessage(FieldByName('MyServerName').AsString);

> Greets, Joost

> "Frank Linde" <li...@lindedaten.de> wrote in message
> news:3AC06821.75BE2D40@lindedaten.de...
> > Hi,

> > how can one read @@-variables (for example: @@ServerName)
> > from MSSQL (using SQL7 and D5 Enterprise)?

> > I tried TQuery with "SELECT @@ServerName" but got no
> > results. The same SQL-Statement in MSSQL-Enterprise-Manager
> > works fine.

> > TIA
> > Frank

Re:How to read @@ServerName from MSSQL 7?


Hi John,

that's it! Thanks for your answer!

Regards
Frank

John Faris schrieb:

Quote

> Try

> SELECT CONVERT(VARCHAR(30),@@SERVERNAME) AS SERVER_NAME

> I believe that SQL server 7 returns @@servername as unicode which the BDE
> does not support - hence the conversion to a type the BDE does support.

> HTH.

> John.

Other Threads