How to determine present database server name - sybase ase - sybase-ase

I need to determine present databse server name where i am running my sql so that i can perform some certain steps depending upon the environment.
Anybody know how to do this ?

the ASE database server name can be found in:
1) in interfaces file (UNIX) or using DSEDIT in Windows
2) running select * from master..sysservers

SELECT ##servername
Why? Because ##servername is a global variable and returns the name of the SAP ASE server.

Related

Connect to a external DB2 with ZendServer

I have been fighting with Zend Server 2018 while trying to connect to a remote AS/400 DB2.
I am using the IBM_DB2 php functions to do the connection but every time I get
[IBM][CLI Driver] SQL1031N The database directory cannot be found on the indicated file system. SQLSTATE=58031 SQLCODE=-1031
Anyone else successful connecting the two?
What I've read online is that I need to catalog the servers.
So I have db2 running on an iseries at say 192.168.50.1 with a name of X232321 and a Windows 10 box running zend server 2018.
What commands would I need to catalog the two servers so I can use the db2 connector? And what does that actually do?
Thanks for the help
Try this on the windows db2 client:
db2 "catalog tcpip node MY_IS remote 192.168.50.1 server 446"
db2 "catalog db MY_ALIAS at node MY_IS"
db2 "catalog dcs db MY_ALIAS as X232321"
You can set MY_IS, MY_ALIAS as you want (no more than 8 letters).
Port 446 may be different for your iSeries host.

SQL Server 2016 _can't start mirror

After upgrading SQL Server 2014 to SQL Server 2016 (both Enterprise editions), I can't start mirror.
This works normally on SQL Server 2014.
After I restore (WITH NORECOVERY) mirror database with full and log backups of primary database I normally run configure setup.
After click on Start mirror I get this error:
Database 'DatabaseName' cannot be open. It is in the middle of a restore. (Microsoft SQL Server, Error:927)
Issue with SQL 2016 GUI. Its worked with TSQL commands.
Mirror Server:
USE MASTER;
GO
ALTER DATABASE SET PARTNER = 'TCP://PrincipalServer:5022'
GO
Principal server:
USE MASTER;
ALTER DATABASE SET PARTNER = 'TCP://MirrorServer:5022'
GO
before executing these commands, you should have Full and log backup restore on DR with no recovery.
I had the same problem. Turns out that some people said that it's a GUI problem. I ran the following TSQL's to solve the problem:
--On Mirror Server, execute the following TSQL:
USE MASTER;
GO
ALTER DATABASE <Database_Name> SET PARTNER = 'TCP://<Principal Server>:5022'
GO
--On Principal Server, execute the following TSQL:
USE MASTER;
GO
ALTER DATABASE <Database_Name> SET PARTNER = 'TCP://<Principal Server>:5023';
GO
ALTER DATABASE <Database_Name> SET WITNESS = 'TCP://<Principal Server>:5024';
GO
Hope it helps.
I had the same error message (and was using SSMS 2016 GUI), however the problem was solved by ensuring that all three instances (principal, mirror and witness) were running as the same (windows) service account.

getting intermittent ORA-12545 error

I am running a monitoring site developed in yii framework using xampp on a windows server machine to check the health of databases. Normally everything works fine but sometimes it gives me the following error:
Code: 12545|Message: CDbConnection failed to open the DB connection: SQLSTATE[HY000]: pdo_oci_handle_factory: ORA-12545: Connect failed because target host or object does not exist (ext\pdo_oci\oci_driver.c:635)
I check ping and everything is fine, tns_ping is working, other users can logon to database and use it. but i get the above error.
PHP Version 5.5.28
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
Oracle Instant Client - 11.2.0.1.0
Windows Server 2012 R2 Standard
PDO Driver for OCI 8 and later enabled
Query used to check if we can connect to database and query it
select count(*) from dual
any help will be appreciated
I assume you are using yii 1 but nevertheless you should try those steps in fixing the error:
In most cases defining the database in your main.php fixes the problem, so try adding: 'connectionString'=>'oci:dbname=mydb',
Disable those extensions: php_pdo_oci8.dll and php_oci8.dll in your php.ini file and leave only the needed one for your environment: php_pdo_oci.dll.
Definitely update your Oracle to 10 or above because according to my experience and some internet forums Oracle client 9 can make some troubles with php 5.1 or above. Not in every scenario but I think it's worth the update.

SQL Server 2012 Express Connection Timeout Expired

Error Message Picture
I installed SQL Server 2012 Express from scratch, but it is not working. Same problem again.
By default, SQL Server Express will install as a named SQLEXPRESS instance - so you need to use your IP address with \SQLEXRPESS added to it as your server name:
Server Name: 192.168.1.199\SQLEXPRESS
Update: you need to go to SQL Server Configuration Manager and find out what your instance name is.
Start Menu
> Microsoft SQL Server 2012
> Configuration Tools
> SQL Server 2012 Configuration Manager
You should see a screen something like this:
Find the entry for SQL Server that is in the "running" state - what does it say in the brackets after SQL Server? That's your instance name - if it's a default SQL Server Express installation, it should say SQLEXPRESS. If it doesn't - well then that's your instance name right there (unless when it's MSSQLSERVER - then it's the unnamed instance).
Use 192.168.1.199\instance-name as your server name

PHP + UnixODBC + FreeTDS - SELECT [field] AS [name] does not work

I have a unix server which has PHP 5.2.13 installed, and it has access to two SQL servers (one is running MSSQL SERVER 2000 and the other MSSQL 2005).
It uses FreeTDS - details:
Version: freetds v0.82
freetds.conf directory: /usr/local/etc
MS db-lib source compatibility: no
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: 8.0
iODBC: no
unixodbc: yes
And I'm using unixODBC-2.3.1
The MSSQL 2000 server is fine, I can run all SQL statements and use mssql_num_rows and mssql_fetch_assoc much as you would with MySQL.
However, the MSSQL 2005 server won't work with mssql_num_rows or mssql_fetch_assoc - you have to use odbc_fetch_row.
That's not really an issue, I assum it's just due to the different server installs.
However, I have a huge issue with the MSSQL 2005 server: I cannot select a field AS another name!
For example:
SELECT
[EnquiryID] AS "The_Key"
FROM [db].[dbo].[table]
Works fine in my admin application (ie: NOT PHP), but if I run the same in my PHP environment, I get:
stdClass Object
(
[PK_EnquiryID] => 1
)
You can see it should be [The_Key] => 1
Has anyone any idea how we can get round this, please? I'm tearing my hair out!
Cheers
Neil
I think this was answered on the freeTDS list, but the problem in is PHP, it makes the wrong call to ODBC so gets the base table name instead of the lable which is what you need in this case.
This is by no means a perfect solution, and I would love to learn the proper way to deal with this issue, but in the mean time, add +'' to each column, after the underlying column name, but before the AS alias and you should be able to circumvent this issue.

Resources