Product:
Cognos Analytics 11.1.7

kit_version=11.1.7-2106251648
CAMAAAWA_version=11.1.7-21
CM_version=11.1.7-54
Microsoft Windows 2016 server

Issue:
How do i install CA11 on my Windows server?

Solution:
Follow the IBM documentation. Here is only a list of things to think about.

https://www.ibm.com/docs/en/cognos-analytics/11.1.0?topic=1117-release-fp3-june-2021

Download the software from IBM

https://www.ibm.com/support/pages/ibm-cognos-analytics-1117-fix-pack-3

You need at least the analytics-installer-2.2.2-win.exe and casrv-11.1.7-2106251648-winx64h.zip.

Check this before installation on your new windows server:

Check that you have remote access to all your Cognos servers
Install SQL 2012 native client for ODBC support to SQL databases

https://download.microsoft.com/download/B/E/D/BED73AAC-3C8A-43F5-AF4F-EB4FEA6C8F3A/ENU/x64/sqlncli.msi

Install NET Framework 4.7.2

https://support.microsoft.com/sv-se/help/4054530/microsoft-net-framework-4-7-2-offline-installer-for-windows

Turn DEP off in Windows control panel
Set Power Options to HIGH Performance in Windows control panel
Turn off IEESC (internet explorer enhanced security configuration)
Check what port your SQL server will use, for access to Content Store and Audit database.
Exclude cognos folders from anti-virus software scanning
Open firewall ports 80, 443 to end users
Open firewall ports 80, 443, 9300, 9362, 4300, 5701, 9301 between servers.
Open firewall ports 1433 for SQL, 25 for Mail, 389 for Active Directory.
Install 7zip and Notepad++ to edit xml files on the server.

 

 

Install IIS on the Windows Server 2016 select Web Server IIS, ASP.NET 4.6, HTTP Activation, TCP Port Sharing, HTTP Redirection, WebDav Publishing, ISAPI Extensions, Websocket, Windows Authentication, IIS Management Scripts and Tools.
Update regedit HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\InetStp\MajorVersion to 9  (only if needed)
Install https://www.iis.net/downloads/microsoft/application-request-routing  or

rewrite_amd64_en-US.msi
requestRouter_amd64.msi

http://download.microsoft.com/download/5/7/0/57065640-4665-4980-a2f1-4d5940b577b0/webfarm_v1.1_amd64_en_us.msi
https://download.microsoft.com/download/1/2/8/128E2E22-C1B9-44A4-BE2A-5859ED1D4592/rewrite_amd64_en-US.msi

https://download.microsoft.com/download/E/9/8/E9849D6A-020E-47E4-9FD0-A023E99B54EB/requestRouter_amd64.msi

Run the installation of Cognos Analytics manually

https://www.ibm.com/docs/en/SSEP7J_11.1.0/com.ibm.swg.ba.cognos.inst_cr_winux.doc/inst_cr_winux.pdf

Get the CA_IIS_Config.bat script from folder D:\Program Files\ibm\cognos\analytics\cgi-bin\templates\IIS and copy it to its own folder, e.g. d:\install

http://www-01.ibm.com/support/docview.wss?uid=swg22000097

Run the installation of the Cognos Analytics developer programs (framework manager)
Update the IIS script with the server name, and run the script CA_IIS_Config.bat
Copy file sqljdbc42.jar into folder d:\program files\ibm\cognos\analytics\drivers

https://download.microsoft.com/download/F/0/F/F0FF3F95-D42A-46AF-B0F9-8887987A2C4B/sqljdbc_4.2.8112.200_enu.exe

Setup a Notification database in SQL, if you have many users in cognos and many scheduled jobs
https://www.ibm.com/docs/en/cognos-analytics/11.1.0?topic=performance-bulk-cleanup-nc-tables
Setup a Content Store and Audit database in your SQL server
Configure Cognos Analytics with FQDN, leave Websphere memory at 8182
Install the CA samples https://revelwood.com/installing-samples-cognos-analytics/

https://www.ibm.com/docs/en/cognos-analytics/11.1.0?topic=samples-downloading-configuring-extended

Setup WebDav in IIS

https://www-01.ibm.com/support/docview.wss?uid=swg22002398&aid=1

Stop creation of dump files, open the cclWinSEHConfig.xml file from the install_location\configuration folder. Set “CCL_HWE_ABORT” value=”0″
Setup the audit database source and copy the D:\Program Files\ibm\cognos\analytics\samples\Audit_samples\IBM_Cognos_Audit.zip file to D:\Program Files\ibm\cognos\analytics\deployment folder. Import the audit samples.
Create a company logo in cognos  https://quebit.com/askquebit/IBM/creating-and-setting-a-default-theme-for-cognos-analytics-11-0-4/ The tags can be different for the different versions.
Tune logging to “Basic” in cognos connection
Activate SSO in Cognos Configuration by adding the advanced property
Name : singleSignonOption

Value: IdentityMapping

https://www.ibm.com/support/pages/how-configure-sso-single-sign-controller-cognos-analytics

Set CAF to exclude *.domain.com and tm1webserver:9510 and tm1webserver:9511
If you also have Cognos Controller then change Security – Authentication in CA11, Inactivity timeout in seconds to 36000
Update Windows TCP windows settings by import below reg values:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]

“MaxUserPort”=dword:0000fffe

“TcpTimedWaitDelay”=dword:00000032

To get login to Planning Analytics with Cognos BI (CAM) you need to change a few files, as below:

Update tm1web.html with tm1web servername and port, like this

var tm1webServices = ["http://tm1servername.domain.com:9510","http://tm1webservername.domain.com:9511"];

Copy tm1web.html to locations;

D:\Program Files\ibm\cognos\analytics\webcontent\bi\tm1\web

D:\Program Files\ibm\cognos\analytics\webcontent\tm1\web

Update pmhub.html with also paw servername and port, like this

var pmhubURLs = ["http://tm1servername.domain.com:9510","http://tm1webservername.domain.com:9511","http://pawservername.domain.com"];

Copy pmhub.html to locations;
D:\Program Files\ibm\cognos\analytics\webcontent

D:\Program Files\ibm\cognos\analytics\webcontent\bi

Update planning.html with also tm1servername and port, like this

var planningServices = ["http://tm1servername.domain.com:9510","http://tm1webservername.domain.com:9511"];

Copy planning.html to same folders as pmhub.html listed above.

The content manager will look in folder D:\Program Files\ibm\cognos\analytics\webcontent for this files, but the Cognos Gateway will look in folder D:\Program Files\ibm\cognos\analytics\webcontent\bi for above files.

 

To prevent scriptable report error  when running sample custom control reports
you need to change the sample reports as below (they are written to only work on port 9300).

The global Sales Report is a sample showing how to use a javascript file with a custom control. These are authored to work ‘out of the box’ via dispatcher but not via a gateway.

To use with a gateway you need to edit the custom control in the report to point to the correct path.

1. Open the ‘Global Sales’ report in Edit mode.
2. select the custom control which is the thin blue box underneath the Prompts and view the properties.
3. In properties under General choose the ‘Module Path’ property and click the ellipsis.
4. By default this path is set to ‘/bi/samples/js/HideShowFilterPanel.js’
5. Please add your gateway to the front of this path so it reads something like:’/ibmcognos/bi/samples/js/HideShowFilterPanel.js’ (where ibmcognos is the name of your gateway virtual directory)
6. Save and re-execute the report.

Setup of jupyter notebook is not covered here, you have to follow the IBM documentation.

https://www.ibm.com/docs/en/cognos-analytics/11.1.0?topic=server-configuring-cognos-analytics-gateway-jupyter-notebook

 

More information:

https://www.ibm.com/support/pages/ibm-cognos-analytics-premises-111x-supported-software-environments

https://www.ibm.com/docs/en/cognos-analytics/11.0.0?topic=configuring-upgrade-cognos-analytics

https://www.ibm.com/docs/en/cognos-analytics/11.1.0?topic=samples-cognos-analytics

https://www.ibm.com/support/pages/scriptable-report-error-when-running-cognos-sample-global-sales-report

https://www.ibm.com/docs/en/cognos-analytics/11.1.0?topic=administration-tuning-server-performance

https://intelalytics.com/blog-and-downloads/f/notes-on-installing-cognos-111x-in-a-windows-environment

Product:
Planning Analytics 2.0.9.10
Microsoft Windows 2016 server

Issue:
I have several Cognos BI servers, where i need to update the planning.html file on, to make SSO work for TM1.

Solution:

On your source TM1 server, create a folder c:\script\tm1.

Create a text file serverslist.txt, where you enter the name or IP address of the servers.

Copy the updated planning.html, pmhub.html and tm1web.html files to this folder.

Create a powershell file, copyfiles.ps1, with this content:

# run the script on the source machine
# remote machines list 
$machines= Get-Content -Path "c:\Script\tm1\serverslist.txt" 
foreach ($onemachine in $machines) 
{ 
Write-Host "Currently the script is copying files on" $onemachine 
Copy-Item -Path "c:\Script\tm1\planning.html" -Destination "\\$onemachine\c$\Program Files\ibm\cognos\analytics\webcontent" -Recurse
Copy-Item -Path "c:\Script\tm1\planning.html" -Destination "\\$onemachine\c$\Program Files\ibm\cognos\analytics\webcontent\bi" -Recurse
Copy-Item -Path "c:\Script\tm1\pmhub.html" -Destination "\\$onemachine\c$\Program Files\ibm\cognos\analytics\webcontent" -Recurse
Copy-Item -Path "c:\Script\tm1\pmhub.html" -Destination "\\$onemachine\c$\Program Files\ibm\cognos\analytics\webcontent\bi" -Recurse
Copy-Item -Path "c:\Script\tm1\tm1web.html" -Destination "\\$onemachine\c$\Program Files\ibm\cognos\analytics\webcontent\tm1\web" -Recurse
Copy-Item -Path "c:\Script\tm1\tm1web.html" -Destination "\\$onemachine\c$\Program Files\ibm\cognos\analytics\webcontent\bi\tm1\web" -Recurse
}

Ensure that the paths are correct for your servers, if you have installed to D: drive you need to update the powershell script to reflect this; “\\$onemachine\d$\Program Files\ibm\cognos\analytics\webcontent\bi\tm1\web”

Start a powershell window as administrator.

The person logged in must have local admin rights on all cognos servers for this to work.

When you run the script it will print out any errors, like above when it can not find the server.

Test the script first in you LAB environment, as it will overwrite any existing files on the CA11 servers.

More Information:

https://www.heelpbook.net/2020/copy-file-to-remote-servers-powershell

Powershell Copy Files | Single | Multiple Computers

https://docs.microsoft.com/en-us/answers/questions/337705/copy-file-to-multiple-remote-computers.html

https://exploringtm1.com/install-planning-analytics-workspace-to-windows-2016/

https://exploringtm1.com/how-to-upgrade-install-planning-analytics-for-excel-pax/

https://exploringtm1.com/how-to-upgrade-planning-analytics-tm1/

Product:
Cognos Enterprise Planning PLANSRVR_version=PLANSRVR-AW32-ML-RTM-10.2.1000.1-0

Cognos Analytics BI kit_version=11.0.12.18062512

Microsoft Windows 2012 R2 server

Problem:

The IBM Cognos service is restarting and people can not work. Error users can get are;

The server did something wrong</faultstring><detail><bus:exception><severity>error</severity><errorCode>DISPATCHER_NOT_YET</errorCode><bus:message><messageString>DPR-ERR-2109 The dispatcher cannot service the request at this time. The dispatcher is still initializing. Contact your administrator if this problem persists.

Suggested solution:

Stop all services.

Export all configuration.

Recreate the internal Cognos certificates.  Follow instructions at the links below.

Open Cognos Configuration and start the service in correct order. The order is very important. CA content manager must be started first.

Please note that the steps are different for different version of Cognos.

More Information:

https://www.ibm.com/support/pages/how-regenerate-cryptographic-keys-cognos-analytics-11

https://www.ibm.com/support/pages/how-regenerate-cryptographic-keys-cognos-1022

https://www.ibm.com/support/pages/how-regenerate-cryptographic-keys-cognos-bi-1021-and-earlier

Product:
Planning Analytics 2.0.9.10   TM1_version=TM1-AW64-ML-RTM-11.0.910.5-0
Microsoft Windows 2016 server

Issue:

How upgrade Planning Analytics to later version?

Suggested solution:
Always follow IBM instructions first, this is a suggestion on what to check for at a installation of TM1.

In the new versions of PA, you can stop the IBM services, and do the installation on top of the existing Planning Analytics folder. This is the recommended way for a upgrade.

Download the latest version from IBM:
https://www.ibm.com/support/pages/ibm-planning-analytics-local-20910-now-available-download-fix-central

https://exploringtm1.com/how-to-download-planning-analytics-local-workspace-excel-and-spreadsheet-services/

For a installation on a Windows server, you need the files that are for windows;

and the latest PAW and PASS…

Check this before installation on your new windows server:

Install Microsoft Visual C++ 2010 SP1 Redistributable Package

https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/vcredist_x64.exe

Install SQL 2012 native client for ODBC support to SQL databases

https://download.microsoft.com/download/B/E/D/BED73AAC-3C8A-43F5-AF4F-EB4FEA6C8F3A/ENU/x64/sqlncli.msi

Install NET Framework 4.8

https://support.microsoft.com/en-us/topic/microsoft-net-framework-4-8-offline-installer-for-windows-9d23f658-3b97-68ab-d013-aa3c3e7495e0

Turn DEP off in Windows control panel
Set Power Options to HIGH Performance in Windows control panel
Turn off IEESC (internet explorer enhanced security configuration)
Start Print spooler service (on the TM1 server)
Exclude cognos and docker folders from anti-virus software scanning
Open firewall ports 80,443,9510,9511 to TM1 end users
Open firewall ports 80,443,9012,9510,9511, 5495,5498,5895,5898, 12300-12400 between servers.
Open firewall ports 9300 for Cognos BI, 1433 for SQL, 25 for Mail, 389 for Active Directory.
Install 7zip and Notepad++ to edit xml files on the server.

 

Setup Planning Analytics local:

If more than one network card, then set the order of there use from powershell command;

Get-NetIPInterface

Set-NetIPInterface -InterfaceIndex 2 -InterfaceMetric 50
Unzip tm1_winx64h_2.0.910.5_ml.tar.gz and Install with issetup.exe
Set maximum memory in MB for WebSphere to 8192 in Cognos Configuration
Check file C:\Program Files\ibm\cognos\analytics\templates\ps\portal\variables_tm1.xml exist on your CA11 server. Rename the variables_tm1.xml.sample file to variables_tm1.xml
Update files planning.html, tm1web.html with tm1web servername and port on CA11 server

// Update the following to point to the location of the planning service(s)
var planningServices = ["http://servername.domain.com:9510","http://servername.domain.com:9511"];

Update file pmhub.html with PAW servername and port on CA11 server

// Update the following to point to the location of the pmhub service(s)
var pmhubURLs = [http://paservername.domain.com:9510","http://paservername.domain.com:9511","http://pawservername.domain.com"];
Set your servers ip, in the tm1s.cfg file to IPAddressV4=”192.168.1.13″  (replace with your ip value)
Update a planning application for use of SSO and CAM in tm1s.cfg with below values;

IntegratedSecurityMode=5

ServerCAMURI=http://caservername.domain.com:9300/p2pd/servlet/dispatch

ClientCAMURI=https://caservername.domain.com/ibmcognos/bi/v1/disp

ClientPingCAMPassport=900

Surf to http://paservername.domain.com:9510/pmpsvc to connect it with a CAM application
To preset the admin host in tm1web, Open D:\Program Files\ibm\cognos\tm1web\webapps\tm1web\WEB-INF\configuration\tm1web_config.xml and change <add key=”AdminHostName” value=”paservername” />

Open D:\Program Files\ibm\cognos\tm1web\webapps\tm1web\WEB-INF\configuration\tm1web_config.xml and change the timeout for the web
<add key=”HttpSessionTimeout” value=”60″ />
Open firewall ports 80,443,9510,9511,8888, 5495,5498,5895,5898,9012 and 12345.. for developers.
CertificateVersion=2 in TM1S.CFG gives that you use 2048-bit encryption internal in TM1
Test to remove any MTQ line in TM1S.CFG for new versions of Planning Analytics
For a new installation create a folder structure for the applications, like d:\tm1\app\datafiles…
Add the PortNumber=12345 (and below numbers) to the tm1s.cfg file for your applications.

HTTPportnumber=12346  (they must be unique for each TM1 application)

ClientMessagePortNumber=12347

Change log time to LOCAL timezone, by in the tm1s-log.properties file edit:

log4j.appender.S1.TimeZone=Local
Where TM1 architect is installed, open C:\ProgramData\Applix\TM1\tm1p.ini and add lines

AllowImportCAMClients = T 

CognosGatewayURI = https://caserver.domain.com/ibmcognos/bi/v1/disp

Language=ENG in TM1P.INI will give English menu in TM1 Architect
https://www.ibm.com/docs/en/planning-analytics/2.0.0?topic=installation-tm1-language-configuration

 

Setup new TM1WEB: IBM Planning Analytics Spreadsheet Services

Install tm1web (PASS) from tm1web-11.0.68-21100620-winx64h_bundle folder by click on exe file

Change to port 9511, in file server.xml, located in the folder C:\Program Files\ibm\cognos\tm1web\wlp\usr\servers\tm1web

Restart the “IBM Planning Analytics Spreadsheet Services”.

To make TM1 APP WEB work, you need to update file pmpsvc_config.xml in folder D:\Program Files\ibm\cognos\tm1_64\webapps\pmpsvc\WEB-INF\configuration with value:

<client id="thinClient" type="html-new" uri="http://paservername.domain.com:9511/tm1web/Contributor.jsp">

Start “IBM Cognos TM1” service, that is for Tm1 App Web (pmpsvc).

Setup Planning Analytics Workspace on Windows 2016

To install to d drive, create c:\programdata\docker\config\daemon.json with this content:

{
"debug": true,
"data-root": "d:\\docker"
}
Run ./Start.ps1

https://www.ibm.com/support/pages/cognos-analytics-and-planning-analytics-integration

If you have issue, use this powershell commands to get more information:

PS C:\> docker version
PS C:\> docker image ls
PS C:\> docker ps --all

PS C:\> Get-VMSwitch
PS C:\> Get-NetNat
PS C:\> Get-ContainerNetwork
Update PAW administration for CAM
IBM cognos BI gateway URI  http://caserver.domain.com:80/ibmcognos/bi/v1/disp

IBM cognos BI Dispatcher URI  http://caserver.domain.com:9300/bi/v1/disp

Change $env:CAMLoginNamespace to same as Namespace ID in Cognos Configuration.

Set timeout to $env:ProxyTimeoutSeconds=900 in file paw.ps1
https://www.ibm.com/docs/en/planning-analytics/2.0.0?topic=local-what-timeout-settings-can-i-set
To get the internal gateway IP for use on windows 2016 server enter:

docker inspect pa-gateway -f' {{.NetworkSettings.Networks.nat.IPAddress}}'
Locate the scripts/shutdown.ps1 script in your Planning Analytics Workspace installation folder.

Copy the scripts/shutdown.ps1 script to a permanent location on your system (d:\ibm\).

In a command window, open the Group Policy Editor (GPE) by running gpedit.msc.

Expand Computer Configuration and select Windows Settings.

Double-click Scripts (Startup/Shutdown).

Switch to the PowerShell Scripts tab.

Click Add and add the shutdown.ps1 script from the folder.

If you need to change port for paw set $env:PAGatewayHTTPPort=”8080” in file paw.ps1
Install the PA agent for the new workspace version on your TM1 server

https://www.ibm.com/docs/en/planning-analytics/2.0.0?topic=components-planning-analytics-administration-agent-local-only

Setup mail for the PA agent

https://pmsquare.com/analytics-blog/2020/11/8/ibm-planning-analytics-system-alerts-via-email

 

How to upgrade PAW:
Download the new version and unzip the file in a new folder e.g. \ibm\paw69

  1. Stop the running paw with command ./scripts/paw.ps1 stop
  2. Copy the /ibm/paw68/config/paw.ps1 file from your current installation to the new installation location (/ibm/paw69/config).
  3. Copy the /ibm/paw68/config/certs directory from your current installation to the new installation location.
  4. Optional: If you configured SSL, copy the /ibm/paw68/config/ssl directory from your current installation to the new installation location.
  5. Install Planning Analytics Workspace Local in the new installation location. See Installing Planning Analytics Workspace Local. Go to the /ibm/paw69/ folder and run ./Start.ps1

    Reply “y” when you are prompted to install the Docker images. Reply “y” when you are prompted to open the administration tool.

 

More Information:

https://www.ibm.com/docs/en/planning-analytics/2.0.0?topic=features-whats-new-in-planning-analytics

https://www.ibm.com/docs/en/planning-analytics/2.0.0?topic=started-planning-analytics-local-installation-configuration

https://exploringtm1.com/how-to-install-planning-analytics-spreadsheet-services/

https://exploringtm1.com/install-planning-analytics-workspace-to-windows-2016/

https://exploringtm1.com/how-to-upgrade-install-planning-analytics-for-excel-pax/

https://exploringtm1.com/how-to-upgrade-planning-analytics-tm1/

https://code.cubewise.com/blog/dealing-with-daylight-saving-time-and-time-zones-in-tm1

How to Upgrade Planning Analytics Workspace (PAW)

Older versions are listed here:

Product:

Cognos Analytics 11

Issue:
The icon to start cognos configuration is gone, how do i start it?

Solution:

For CA 11 kit_version=11.0.12.18062512
kit_name=IBM Cognos Analytics

Run D:\Program Files\ibm\cognos\analytics\bin64\cogconfig.bat

For CA 11kit_version=11.0.13.19030518
kit_name=IBM Cognos Analytics

Run “C:\Program Files\ibm\cognos\analytics\bin64\cogconfigw.exe”

For CA kit_version=11.1.7-2106251648
Manifest=casrv-manifest-11.1.7-2106251648-winx64h.json
Installer=analytics-installer-2.2.2-win.exe

Run D:\Program Files\ibm\cognos\analytics\bin64\cogconfigw.exe

More information:

https://www.ibm.com/docs/en/cognos-analytics/11.1.0?topic=analytics-cognos-configuration-command-line-options

https://www.ibm.com/support/pages/ibm-cognos-analytics-1117-fix-pack-3

Product:
Microsoft SQL server 2016

Issue:
Try to find what a users have for access rights inside a database.

Suggested solution:

Enter this code as sysadmin, to find person access rights in one database:

EXECUTE AS LOGIN = 'YourDomain\User.Name' --Change This

USE database  --Change This

GO

SELECT * FROM fn_my_permissions(null, 'database');

REVERT

Enter this to see what databases a person have access to

EXECUTE AS LOGIN = 'YourDomain\User.Name' --Change This
SELECT [name]
FROM MASTER.sys.databases
WHERE HAS_DBACCESS([name]) = 1
REVERT

To find your rights in the current database:

SELECT * FROM fn_my_permissions(null, 'database');

To list dbowners

SELECT user_name(member_principal_id)

FROM   sys.database_role_members

WHERE  user_name(role_principal_id) = 'db_owner'

More Information:

https://stackoverflow.com/questions/7048839/sql-server-query-to-find-all-permissions-access-for-all-users-in-a-database

http://www.sqlnuggets.com/blog/sql-scripts-check-logins-permissions/

http://www.sqlnuggets.com/blog/sql-scripts-list-databases-a-login-can-access/

https://sqlgeekspro.com/users-db_owner-access-databases/

https://www.sqlserver-dba.com/2015/05/find-database-users-mapped-to-db_owner-role.html

https://schottsql.blogspot.com/2016/04/getting-all-permissions-for-server.html

fn_my_permissions() – Sprawdzenie jakie mamy uprawnienia do bazy danych

Product:
Microsoft SQL server 2016

Issue:
When moving a SQL database to a different Windows server, you want to check the other database if they have any SP reference to that database.

Solution:

This query will loop all database and run the select statement on each, and find any store procedure that contain the word “foo”.

EXEC sp_MSforeachdb 'USE ? SELECT ROUTINE_CATALOG,ROUTINE_SCHEMA,ROUTINE_NAME, ROUTINE_DEFINITION, LAST_ALTERED

FROM INFORMATION_SCHEMA.ROUTINES 

WHERE ROUTINE_DEFINITION LIKE ''%foo%'' 

AND ROUTINE_TYPE=''PROCEDURE'' 

ORDER BY ROUTINE_NAME'

 

It is necessary to set the database for the query to run against, by using the USE ? statement, otherwise the code will execute in the context of the current database.

You can also use this to search inside one database:

SELECT ROUTINE_NAME, ROUTINE_DEFINITION

FROM INFORMATION_SCHEMA.ROUTINES 

WHERE ROUTINE_DEFINITION LIKE '%foo%' 

AND ROUTINE_TYPE='PROCEDURE'

ORDER BY ROUTINE_NAME

 

or use below, as above have a limit of searching only the first 8000 characters of the stored procedure.

SELECT OBJECT_NAME(object_id), definition

    FROM sys.sql_modules

    WHERE OBJECTPROPERTY(object_id, 'IsProcedure') = 1

    AND definition LIKE '%foo%'

 

More information:

https://www.mytecbits.com/microsoft/sql-server/search-find-stored-procedure

https://www.mssqltips.com/sqlservertip/1414/run-same-command-on-all-sql-server-databases-without-cursors

http://www.bradleyschacht.com/search-stored-procedure-text/

Product:

Microsoft SQL server 2016

Issue:

Is there someone inside the database?

Suggested Solution:

Run this SQL script to see who have logged in to the database:

select 

@@servername as [ServerName],

getdate() as RunTime, 

spid, DB_NAME(dbid) as DatabaseName, 

login_time, 

last_batch, 

hostname, 

program_name, 

nt_domain, 

nt_username, 

loginame 

From master..sysprocesses

 

To get more information, like kerberos, run this SQL script:

select c.auth_scheme,* from sys.dm_exec_sessions s join sys.dm_exec_connections c on s.session_id=c.session_id where s.host_name ='servername'

To see active connections:

EXEC sp_who2 'active';

More Information:

https://www.sqlservercentral.com/articles/is-this-database-being-used

Product:

Microsoft SQL server 2016

Issue:

Error when testing linked servers in SQL server.

Solution:

Ensure the port is open first, by start PowerShell on the from server and use Test-NetworkConnection.  Enter below to check port 1433;

tnc servername -port 1433

If firewall is open, and you get a error saying “anonymous login” then the kerberos delegation does not work. You need to check that your account (or the account that run the SQL agent service) is allowed to be delegated, check with this power-shell command;

Get-ADUser -Filter {SamAccountName -eq "YourAccountSamName"} -Properties msDS-AllowedToDelegateTo | Select-Object -ExpandProperty msDS-AllowedToDelegateTo

You must check that the SQL server machine, have in AD allow to delegate, you do this with this PowerShell command (for both servers);

Get-ADComputer ComputerName -Properties * | Format-List -Property *delegat*,msDS-AllowedToActOnBehalfOfOtherIdentity

TrustedForDelegation must be True.

Ask the Active Directory team to correct above.

 Get-ADServiceAccount -Filter {SamAccountName -eq "YourServiceAccuntNameHere"} -Properties * | Format-List -Property *delegat*

Above need to be used, if the account is a Service Account in AD.

https://docs.microsoft.com/en-us/powershell/module/activedirectory/get-adserviceaccount?view=windowsserver2022-ps

More information:

Microsoft Made an Easy Button for SPN and Double Hop Issues

Double-Hop Linked Servers

https://help.zaptechnology.com/zap%20cubexpress/currentversion/content/topics/HowTo/UsingSPN.htm

https://social.technet.microsoft.com/wiki/contents/articles/717.service-principal-names-spn-setspn-syntax.aspx

https://kb.parallels.com/en/124644

https://www.sqlshack.com/how-to-create-and-configure-a-linked-server-in-sql-server-management-studio/

https://www.mssqltips.com/sqlservertip/6083/understanding-sql-server-linked-servers/

https://www.c-sharpcorner.com/UploadFile/suthish_nair/linked-servers-in-sql-server-2008/

https://en.hackndo.com/constrained-unconstrained-delegation/

https://www.microsoft.com/en-us/download/details.aspx?id=39046&WT.mc_id=soc-n-%5bTR%5d-loc-%5bServices%5d-%5bfarukc%5d

Product:

Microsoft SQL server 2016

Issue:

SQL agent can not send mail. There is no error in windows event log, and no errors in SQL server log.

Solution:
Install NET Framework 3.5 on your SQL server.  Download from here:

https://www.microsoft.com/en-us/download/details.aspx?id=25150

SQL server 2016 demands Net Framework 3.5 for the mail function to work.

Check if NET Framework is installed on your server in folder:

C:\Windows\Microsoft.NET\Framework64

Folder is missing from the SQL server where SQL Mail is not working.

On a SQL server, where mail function is okay, the v3.5 folder exist.

You can also test this by go to the SQL server, start a command prompt, and go to folder

C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Binn

Run DataBaseMail.exe

If you get a error that Net Framework can not be installed, then this is the problem.

Please note that the windows account that run the SQL Server Agent (MSSQLSERVER) must have access rights to the Net Framework 3.5 folder and its files.

You can check if SMTP mail host is working by run below PowerShell command:

Send-MailMessage -To "your.mail@company.com" -From "noreply@company.com"  -Subject "Test mail powershell" -Body "Some important plain text!" -Credential (Get-Credential) -SmtpServer "smtp-servername" -Port 25

If that works, then the SMTP and firewall is correct. Then you need to check SQL servers settings;

SELECT [sysmail_server].[account_id],

       [sysmail_account].[name] AS [Account Name],

       [servertype],

       [servername] AS [SMTP Server Address],

       [Port]

FROM [msdb].[dbo].[sysmail_server]

     INNER JOIN [msdb].[dbo].[sysmail_account] ON [sysmail_server].[account_id] = [sysmail_account].[account_id];

Above gives you the SMTP setup

EXEC msdb.dbo.sysmail_help_queue_sp @queue_type = 'Mail';
Above will show the status of the mail log
SELECT TOP (1000) [profile_id]
,[name]
,[description]
,[last_mod_datetime]
,[last_mod_user]
FROM [msdb].[dbo].[sysmail_profile]

Above will show the SQL Mail profiles.

More information:

Troubleshooting Database Mail Failures

https://www.sqlshack.com/configure-database-mail-sql-server/

Check version of SQL server : https://sqlserverbuilds.blogspot.com/