Skip to main content

Posts

AWS Service Catalog Rule Functions - Cloudformation Fn::Contains Example

I came across an YAML Cloudformation template that was failing validation with the following error: Cannot convert the template because of an error:: unknown tag !<!Contains> at line... The !Contains function is part of AWS Service Catalog, and it is meant to give more control and flexibility when creating your company's stacks. The challenge is that the current AWS Service Catalog documentation only provides examples in JSON format, leaving YAML users at their own luck. Fiddling around in different forums, I happened to notice that YAML can recognize the JSON pattern of the Contains function ( 'Fn::Contains' ) So in order to make the YAML code work, I replaced !Contains with 'Fn::Contains' See the examples below: JSON     "Rules": {         "AuroraDBInstanceTypeRule": {             "RuleCondition": {                 "Fn::Equals": [     ...
Recent posts

Hortonworks Installation - Keyserver Connection

Trying to install Hortonworks on Ubuntu 18, I was not able to connect to the keyserver using: apt-key adv --recv-keys --keyserver keyserver.ubuntu.com B9733A7A07513CAD to fix this i used the following instead apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 B9733A7A07513CAD This is the successful output: Executing: /tmp/apt-key-gpghome.abd3V0BdXN/gpg.1.sh --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 B9733A7A07513CAD gpg: key B9733A7A07513CAD: public key "Jenkins (HDP Builds) <jenkin@hortonworks.com>" imported gpg: Total number processed: 1 gpg:               imported: 1

SQL Server connection using windows authentication from a different domain

I had to connect to a SQL Server database from my laptop that is not on the same domain as the DB server. I'm using JTDS to connect to the DB, in this case using Talend. On the first few attempts I received this error: The login is from an untrusted domain and cannot be used with Windows authentication After playing with many different parameter combinations,  I finally managed to have a successful connection using the following connection string: jdbc:jtds:sqlserver://<SERVERIP>:<PORT>/<DATABASE>;instance=<INSTANCE>;useNTLMv2=true;domain=<DOMAIN>;user=<LOGIN>;password=<PASSWORD> This is the screenshot of the connection configuration on Talend: And the output of the 'Test connection':

SQL Server Setting Session Information

Oracle has a functionality to set information to an application or user session using  DBMS_APPLICATION_INFO . On Microsoft SQL a similar functionality can be achieved using  dm_exec_requests context_info field. To set that information use: DECLARE @Info BINARY(128) = CAST('XYZ Session' AS BINARY(128)) SET CONTEXT_INFO @Info When querying dm_exec_requests you can see the information you set on the session select CAST(req.context_info AS VARCHAR(128)) as char_context_info, session_id, start_time, status, command FROM sys.dm_exec_requests req XYZ Session,90,2019-02-14 10:03:48.140,running,SELECT

MS SQL Server loop through a list of strings

SQL Server does not have a straight forward way to do a For Loop with a list of string values. The easiest solution I found, can be seen below: DECLARE @ list varchar ( 8000 ) DECLARE @pos INT DECLARE @ len INT DECLARE @ value varchar ( 8000 ) SET @ list = 'A101,A203,B12341,C124,' set @pos = 0 set @ len = 0 WHILE CHARINDEX ( ',' , @ list , @pos+ 1 )> 0 BEGIN set @ len = CHARINDEX ( ',' , @ list , @pos+ 1 ) - @pos set @ value = SUBSTRING (@ list , @pos, @ len ) PRINT @ value -- for debug porpose --DO YOUR MAGIC HERE set @pos = CHARINDEX ( ',' , @ list , @pos+@ len ) + 1 END Please check the original website: https://www.admfactory.com/split-a-string-and-loop-in-sql-server/

Use windows authentication out of the domain

You don't need to have your computer on the domain to use Windows Authentication. Just use the runas command (tested on Windows 10 Home) This is my SQL Server Management Studio shortcut: "C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\Ssms.exe"  Create a copy of the shortcut and change the target, adding the following to the beginning: %windir%\System32\runas.exe /netonly /user:domain\username  The full target in my shortcut looks like this: %windir%\System32\runas.exe /netonly /user:domain\username "C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\Ssms.exe" Notice that I also changed the Shortcut Name to Windows Authentication and the icon as well   When I double click the new shortcut, I'm asked for my domain user password And once I'm authenticated, I can open a database using Windows Authentication.