Quote macrovariables e.g. for an IN SQL-statement

The code below lets you qoute the contant of a macrovariables e.g. to be used in an IN SQL-statement.

%let Variables = age height weight;
%let InStatement = %Str(%’)%sysfunc(Tranwrd(&Variables.,%Str( ),%Str(%’, %’)))%Str(%’);

The macrovariable InStatement will contain ‘age’,’height’,’weight’. And can then be used in an IN SQL-statement.

Security Token was not recognized by the IssuerNameRegistry

When you try to connect to a provider with a certificate, you can get the message below e.g. in your Windows Event Viewer under Application.

The issuer of the Security Token was not recognized by the IssuerNameRegistry. To accept Security Tokens from this issuer, configure the IssuerNameRegistry to return a valid name for this issuer.

If you are using the thumbprint of the certificate in the web.config everything might seem to be correct. But the problem can be that you copied the thumbprint from the certificate. When you copy the thumbprint from the certificate you get an extra “invisible” stop-character (shown with yellow below) included in the copy and the pasting to the web.config. Don’t copy the thumbprint from the certificate. Just type it in manually.

Certificat

Getting information about your SAS-installation

Below is a couple of commands that can be used to get information about your SAS-installation.

proc setinit;
run;

The Setinit-command will give you information about the SAS-products that your SAS-installation is licensed for.

proc product_status;
run;

The Product_status-command will give you information about the SAS-products installed on your system.
Keep in mind that there could be a difference between what’s licensed on your system and what’s actually installed.
The commands above will only give you information about the products installed for base-SAS. If you want information about what other SAS-products is installed on you system, then you can get this SAS-program from SAS and run it on your system.

Runas user on other domain

The command below will let you run a program as another user on another domain.

runas /netonly /user:<domain>\<user> "<program>"

If you want to run SQL Server Management Studio 2014 you would use the command below.

runas /netonly /user:<domain>\<user> "C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\Ssms.exe"

Add trigger to all tables in schema

The code below will add a trigger to all the tables in a specific schema on the Microsoft
SQL-server.

-- Uses the build-in stored procdure in Microsoft SQL-server to run through all tables.
EXEC sp_MSForEachTable 
-- Initial command for the DB to use.
@precommand = 'use <db>',
-- Check if trigger already exists on table. If it does drop/delete it.
@command1 = 
'
IF OBJECT_ID(''[user].[?_trig]'', ''TR'') IS NOT NULL
BEGIN
	DROP TRIGGER [user].[?_trig]
END
',
-- Create trigger on all tables in a specific schema.
@command2 = '
CREATE TRIGGER [?_trig]
ON ?
AFTER INSERT
AS
	SET NOCOUNT ON
	INSERT [<schema>].[<table>] ([<column1>], [table_name], [dtNow])
	SELECT <columnname>, ''?'', CURRENT_TIMESTAMP FROM ?
GO
',
-- Only look at tables in a specific schema.
@whereand = 'and upper(schema_name(schema_id)) = ''<SCHEMA>'''
go