Average time of disk dccess read/write in DB2

Through DB2 we can get the average time in ms disk access is having DB2. These times are crucial for the detection of a IO problem with DB2 instance.

Usually we take into consideration that a value close to 2-3ms is good, more than 10ms can indicate problems.

Avg ms/write:

select trunc(decimal(sum(pool_write_time))/decimal(

(sum(pool_data_writes)+sum(pool_index_writes))),3)

from sysibmadm.snaptbsp

 

Avg ms/read:

How to know the DB2 connection port

Maybe there are other methods, in this short article, a simple way to know the port that serves DB2 server.

We get the name of the service TCP / IP:

> db2 get dbm cfg | grep SVCENAME

Capture the result:

TCP/IP Service name (SVCENAME) = db2TRP

Look at /etc/services:

> cat /etc/services | grep sapdb2QRP

db2TRP 5912/tcp # DB2 Communication Port

 

The listening port is 5912!

DB2 Write Suspend

When doing a snapshot from a storage array, if the server contains a DB2 instance running, there is no certainty that the snapshot contains a consistent copy of the database.

To launch a snapshot and ensure consistent copy in DB2 is possible to put the database at “write suspend”, that is, it overrides the disk access in write mode, and work in the buffer pool memory. Queries whether it will record but writes are performed only in memory.

How to use Openquery to make a join between a SSAS cube and a table from any other database

Connetion to SSAS instanceImagine you need a report with data from an OLAP sales cube, and have to include data from a table of the relational data source, or from an external database.

With a linked server you can construct a MDX query in the SQLServer instance where you have the cube, joining with an external database to complete the data with information from tables of the relational database..

How to change in SQL Server the key column to an identity by using T-SQL and OVER clause

Relational model with invoices master-detailIf you have to change the type of a key column on SQL Server, and the new column type has to be integer, and even identity, you can do it by using some criteria in order to get the rows ordered (PK= index clustered= order by in physical disk by this column)..

We will change the type of the PK column of a table in a sample with 2 typical invoice tables master-detail where the key columns are nchar. 'invheader.invoiceid' is the primary key of the master table and 'invlines.lineid' is the primary key of the detail table..

 

How to recover the password of the user sa on SQL Server

Init params con SQL Server Configuration ManagerWith SQL Server, when we forget or we lose the password of the DBA user 'sa', and we are the administrators of the database, we have a little problem.

It's easy to forget this password because probably we have our own user administrator and don't use to log in with the sa account. We also could have inherited the administration of a SQL Server database, with any documentation about the sa account or we coul'd have installed a database and deleted the login with admin privileges without knowing the password of the sa user.

For all this situations there is a better solution than reinstalling the database..

How to do an update from a select with summarized registers in SQLServer

Update from summarized registerA very powerful way to do a table's update in a SQL Server database is to link it with another table with a join, and updating the fields of everyone of its registers using the field's values of the registers linked with the another one. This technique had been discussed in the forum post Update with join or update from select in SQL Server..

Avoiding errors concatenating fields with numerical values in SQL Server

concatenate stringsThe operator to concatenate in SQL Server is '+', but this operator is also used to add values.

 

Being the same operator for both, the query analyzer makes a concatenation or a sum based on the type of data fields being treated. If the fields are of 'string' type, the operator concatenate, and if it has numeric fields, two integers, for example, it add the two values.

Tips for UPSERT or update using insert in SQL Server

Merge SQL

In many cases, especially in ETL processes or data loading to a data warehouse, for example, we would rather use a single sentence or the checking of the existence of a register and its updating. If register doesn't exist we would want to insert it. This combination has been nicknamed UPSERT, although in SQL there is a specific statement to make it, which is MERGE.