Posts

Detect unicode downgrade fail (nvarchar to varchar)

;WITH unicodeDataSource AS (   SELECT N'Hello' AS Text , N'English' AS Language UNION ALL   SELECT N'Здравствуйте' AS Text, N'Russian' AS Language UNION ALL   SELECT N'こんにちは' AS Text, N'Japanese' AS Language UNION ALL   SELECT N'Hallå' AS Text, N'Swedish' AS Language  ) SELECT *,    iif( s.Text = cast(cast(s.Text AS varchar(100)) AS nvarchar(100))      ,1,0) AS CastWasSuccessful FROM unicodeDataSource s Result Text Language CastWasSuccessful Hello English 1 Здравствуйте Russian 0 こんにちは Japanese 0 Hallå Swedish 1

Get ISO data time SSIS expression

replace(substring((dt_str,30, 1252) getdate(), 1, 23)," ","t")

SSIS circular precedence constraints exists!

Image
Yes, you can create circular precedence constraint chains in SSIS packages. At least if you automate! Using BIML (which has no check for stupidity). It does what it's told. So investigate your generated packages carefully. Probably your mysteriously failing master package arrived at this if you have the same symptoms as I had When running from Sql Server Agent : Unexpected Termination (No messages) When running in Visual Studio : Starting / Cancelled in output window. Hanging of Visual Studio Windows log  Faulting application name: devenv.exe, version: 16.2.29306.81, time stamp: 0x5d72c031 Faulting module name: DTS.dll, version: 2019.150.1301.433, time stamp: 0x5d1ee90e Exception code: 0xc00000fd 0xc00000fd  seem to indicate buffer overflow (infinite loop clue!) Update: This is reported by ClemJax in  https://github.com/varigence/BimlPit/issues/98

How to decrypt stored password from SSMS registered servers

Image
Right click your server, choose tasks/export Uncheck "Do not include user names and passwords in the export file" Save the export to a file Open the file in an editor and locate the tag RegisteredServers:ConnectionStringWithEncryptedPassword Copy the contents of password attribute Open powershell and paste the code below, after you amend it with your encrypted string. $base64pass = "PasteEncryptedPasswordHere" [System.Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null [System.Text.Encoding]::Unicode.GetString([System.Security.Cryptography.ProtectedData]::Unprotect([System.Convert]::FromBase64String($base64pass), $null, [System.Security.Cryptography.DataProtectionScope]::CurrentUser))

Biml metadata connection snippet

var metadataConnection = SchemaManager.CreateConnectionNode( "db_metadata" , RootNode.Connections[ "db" ].RenderedConnectionString); List< string > includedSchemas = new List< string >{ "schema1" }; List< string > includedTables = null ; var metadataSchema = metadataConnection.GetDatabaseSchema( includedSchemas, includedTables, ImportOptions.None); foreach ( var t in metadataSchema.TableNodes) { //perform biml magic }

Decrypted @on_success_action and @on_failure_action snippet for sp_add_jobstep

declare    @quitWithSuccess tinyint = 1,   @quitWithFailure tinyint = 2,   @gotoNextStep tinyint = 3,   @gotoStep tinyint = 4

Insert bulk statement does not support recompile (SQL 2017)

This happened to me once, source and target databases was located on the same server running 14.0.1000.169 Microsoft SQL Server Enterprise (64-bit) Consecutive executions never fail. I could not reproduce the error until next day. My workaround has been to simply add "re-try execution" a number of times in SQL Agent job. SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005.  An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80004005  Description: "Insert bulk statement does not support recompile.".  End Error