Blog Pages

Get database schema changes history (by T-SQL query)

DECLARE @db_name TABLE
(
       db_name_ID int identity,
       DBName sysname
);
DECLARE @objects TABLE
(
       db_name sysname,
       ob_name sysname,
       type nvarchar(60),
       date datetime,
       s_name sysname
);

DECLARE @cnt int;
DECLARE @DBName sysname;

INSERT INTO @db_name
       (DBName)
       VALUES ('Your_Database_Name')
       -- OR SELECT name FROM sys.databases WHERE database_id <> 2;

SELECT @cnt = COUNT(*) FROM @db_name;

WHILE @cnt > 0
BEGIN
       SELECT @DBName = DBName FROM @db_name WHERE db_name_ID = @cnt;
      
       INSERT INTO @objects
              exec('use ['+@DBName+']; SELECT '''+@DBName+''' as db_name,o.name as object_name,o.type_desc, o.modify_date, s.name as schema_name from sys.all_objects o left outer join sys.schemas s
                             on (o.schema_id = s.schema_id) where modify_date > ( GETDATE() -3000);');
      
       SET @cnt = @cnt-1;
END

SELECT *
FROM @objects
       --where ob_name = 'Your_Object_Name'
ORDER BY date desc, db_name, s_name, ob_name;


SSIS, TVP: An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80040E21 Description: "Invalid character value for cast specification"

Error:
An OLE DB record is available. Source: "Microsoft SQL Server Native Client 11.0" Hresult: 0x80040E21 Description: "Invalid character value for cast specification".

Cause:
Not fit parameter declaration.

But:
If your all parameters were declared well, but you still have this error, and one of the parameter is a TVP (Table Variable Parameter):
The TVP is the cause...
I tried to pass a SSIS Object to TVP in the stored procedure, and I've got this error.

Solution:
I pass the data to a temp table in the destination DB, and took it from there to the SP.


SSIS: resize container to proportional size

Problem:
Anyone who worked with SSIS gets crazy from the tries to resize the containers to proportional size…

Solution: