SSIS Package Not Running as 32bit in SQL Server 2012

By default, everything will run in 64 bit on the servers. To change this behaviour, you need to indicate that the 32bit version of dtexec should be used. For the 2012 SSISDB, we have two easy ways of invoking our packages: SQL Agent and the catalog.start_execution method. catalog.start_execution For single serving package runs, you can … Read more

Convert from DateTime to INT

EDIT: Casting to a float/int no longer works in recent versions of SQL Server. Use the following instead: select datediff(day, ‘1899-12-30T00:00:00′, my_date_field) from mytable Note the string date should be in an unambiguous date format so that it isn’t affected by your server’s regional settings. In older versions of SQL Server, you can convert from … Read more

Export Varbinary(max) column with ssis

Whilst awaiting clarification on how you intend to use it, I’d suggest looking at the Export Column Transformation. Similar need on this question Using SSIS to extract a XML representation of table data to a file I banged out a quick example that illustrates how to do export varbinary data. The following query concatenates some … Read more

Temporarily disable all foreign key constraints

To disable foreign key constraints: DECLARE @sql nvarchar(max) = N”; ;WITH x AS ( SELECT DISTINCT obj = QUOTENAME(OBJECT_SCHEMA_NAME(parent_object_id)) + ‘.’ + QUOTENAME(OBJECT_NAME(parent_object_id)) FROM sys.foreign_keys ) SELECT @sql += N’ALTER TABLE ‘ + obj + N’ NOCHECK CONSTRAINT ALL; ‘ FROM x; EXEC sys.sp_executesql @sql; To re-enable: DECLARE @sql nvarchar(max) = N”; ;WITH x AS … Read more

Dynamically assign filename to excel connection string

Option A The ConnectionString property for an Excel Connection Manager is not where I go to manipulate the current file, which is contrast to an ordinary Flat File Connection Manager. Instead, put an expression on the Excel Connection Manager’s ExcelFilePath property. In theory, there should be no difference between ConnectionString and ExcelFilePath except that you … Read more