Thursday, September 20, 2007

Mapping SQL Server 2000 System Tables to SQL Server 2005 System Views

This topic shows the mapping between the SQL Server 2000 system tables and functions and the SQL Server 2005 system views and functions.

The following link show how to maps the system tables that are in the master database in SQL Server 2000 to their corresponding system views or functions in SQL Server 2005.

This information is provided by Microsoft here.

SQL Server 2005 System Views Map

The Microsoft SQL Server 2005 System Views Map shows the key system views included in SQL Server 2005, and the relationships between them.

You can download the .PDF poster here.

Who is friend? Who? :-)



Tuesday, September 11, 2007

BCPs IN / OUT (á lá Sybase) vs Data Export/Import Wizard SS2005

Exemplo de 2 Scripts que criam os comandos necessários para Exportar / Importar dados de uma BD de Origem para uma BD de Destino.
Muito util para a versão SQL2005, pois o Wizard Export Data está uma verdadeira DESGRAÇA!!!

Para Exportar os Dados:

USE [DBName]
GO


Select 'BCP "DBName.dbo.' + name + '" OUT "PathExportFiles\BCPOUT\' + name + '.OUT" -w -t"{{[[", -r"}}]]" -S %ServerName% -U%Username% -P%Password% -e "PathExportFiels\Error.txt"'
from sysobjects where xtype = 'u'

Gravar os Resultados num .Bat file e evocar através de uma Linha de Comandos...

Para Importar os Dados:

USE [DBName]
GO


Select 'BULK INSERT ' + name + ' FROM ''IMPORTFILEPATH\BCPIN\' + name + '.OUT '' WITH ( DATAFILETYPE = ''widechar'', FIELDTERMINATOR = ''{{[['', ROWTERMINATOR = ''}}]]'', CODEPAGE=''850'')'
from sysobjects where xtype = 'u'