MSSQL'de Netsis Ait İki Databese 'deki Tablo Yapılarını Karşılaştırmak
-- Veritabanı ve tablo isimlerini değişkenler olarak tanımlayın
DECLARE @Database1 NVARCHAR(128) = 'VENCO240824';
DECLARE @Database2 NVARCHAR(128) = 'VENCO';
DECLARE @TableName NVARCHAR(128) = 'TBLSTSABIT';
-- Sütun yapısı karşılaştırması
SELECT
COALESCE(c1.COLUMN_NAME, c2.COLUMN_NAME) AS ColumnName,
c1.DATA_TYPE AS DataType_DB1,
c1.CHARACTER_MAXIMUM_LENGTH AS CharMaxLength_DB1,
c1.NUMERIC_PRECISION AS NumericPrecision_DB1,
c1.NUMERIC_SCALE AS NumericScale_DB1,
c2.DATA_TYPE AS DataType_DB2,
c2.CHARACTER_MAXIMUM_LENGTH AS CharMaxLength_DB2,
c2.NUMERIC_PRECISION AS NumericPrecision_DB2,
c2.NUMERIC_SCALE AS NumericScale_DB2
FROM
(SELECT * FROM [VENCO240824].INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = @TableName) c1
FULL OUTER JOIN
(SELECT * FROM [VENCO].INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = @TableName) c2
ON
c1.COLUMN_NAME = c2.COLUMN_NAME
WHERE
c1.COLUMN_NAME IS NULL
OR c2.COLUMN_NAME IS NULL
OR c1.DATA_TYPE <> c2.DATA_TYPE
OR ISNULL(c1.CHARACTER_MAXIMUM_LENGTH, 0) <> ISNULL(c2.CHARACTER_MAXIMUM_LENGTH, 0)
OR ISNULL(c1.NUMERIC_PRECISION, 0) <> ISNULL(c2.NUMERIC_PRECISION, 0)
OR ISNULL(c1.NUMERIC_SCALE, 0) <> ISNULL(c2.NUMERIC_SCALE, 0)
ORDER BY ColumnName;
Uygulama ve Destek İçin:
Onem Bilişim İletişim Ltd. Şti.