-- Databaselerdeki varsa tablolar silinir USE KNetSubDB2 GO IF OBJECT_ID('dbo.ShortListDB_Gecis_Sil', 'U') IS NOT NULL DROP TABLE [KNetSubDB2].[dbo].[ShortListDB_Gecis_Sil]; GO
-- Tablolar SELECT * INTO ile olusturulur SELECT TOP 10 * INTO [KNetSubDB2].[dbo].[ShortListDB_Gecis_Sil] FROM [KNetSubDB2].[dbo].[ShortListDB] WITH(NOLOCK) GO
-- Tablolar TRUNCATE edilir TRUNCATE TABLE [KNetSubDB2].[dbo].[ShortListDB_Gecis_Sil] GO
-- Tablolardaki istenilen degisiklik yapilir ör:SepetNo alanlar decimal 6 çekilir ALTER TABLE [KNetSubDB2].[dbo].[ShortListDB_Gecis_Sil] ALTER COLUMN [SepetNo] decimal(6,0) NOT NULL GO
-- Data Eklenir SET IDENTITY_INSERT [KNetSubDB2].[dbo].[ShortListDB_Gecis_Sil] ON GO INSERT INTO [KNetSubDB2].[dbo].[ShortListDB_Gecis_Sil] (MusteriRefNo, SepetNo, AdayRefNo, PostingDate, PostingDateN, hosaday, DummyId, BasvuruDateN, ALoginId, CLoginId, Kaynak, AvID, CreationDate, LastModifyDate, ShortListID) SELECT MusteriRefNo, SepetNo, AdayRefNo, PostingDate, PostingDateN, hosaday, DummyId, BasvuruDateN, ALoginId, CLoginId, Kaynak, AvID, CreationDate, LastModifyDate, ShortListID FROM [KNetSubDB2].[dbo].[ShortListDB] WITH(NOLOCK) GO SET IDENTITY_INSERT [KNetSubDB2].[dbo].[ShortListDB_Gecis_Sil] OFF GO
-- Key ve Cosntraintler eklenir.Sub2 ALTER TABLE [KNetSubDB2].[dbo].[ShortListDB_Gecis_Sil] ADD CONSTRAINT DF_ShortListDB_Gecis_Sub2_hosaday DEFAULT (0) FOR hosaday GO ALTER TABLE [KNetSubDB2].[dbo].[ShortListDB_Gecis_Sil] ADD CONSTRAINT DF_ShortListDB_Gecis_Sub2_DummyId DEFAULT (0) FOR DummyId GO ALTER TABLE [KNetSubDB2].[dbo].[ShortListDB_Gecis_Sil] ADD CONSTRAINT DF_ShortListDB_Gecis_Sub2_CreationDate DEFAULT getdate() FOR CreationDate GO ALTER TABLE [KNetSubDB2].[dbo].[ShortListDB_Gecis_Sil] ADD CONSTRAINT DF_ShortListDB_Gecis_Sub2_LastModifyDate DEFAULT getdate() FOR LastModifyDate GO ALTER TABLE [KNetSubDB2].[dbo].[ShortListDB_Gecis_Sil] ADD CONSTRAINT PK_ShortListDB_Gecis_Sub2 PRIMARY KEY CLUSTERED ( MusteriRefNo, SepetNo, AdayRefNo ) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [FG]
GO
--Indexler Olusturulur Sub2 USE [KNetSubDB2] GO
/****** Object: Index [IX_AdayRefNumber] Script Date: 8.9.2019 16:51:12 ******/ CREATE NONCLUSTERED INDEX [IX_AdayRefNumber_Gecis_Sil] ON [dbo].[ShortListDB_Gecis_Sil] ( [AdayRefNo] ASC )WITH (ONLINE=ON, FILLFACTOR = 85) ON [FG] GO
-- Tablo Adları değiştirilir. Sub 2 -- once orjinal tablo adi olmayan bir tablo adina donusturulur USE [KNetSubDB2] GO EXEC sp_rename 'dbo.ShortListDB', 'ShortListDB_HEDE'; GO -- sonra bizim hazirladigimiz tabloyu, orjinal tablo adina donusturuyoruz USE [KNetSubDB2] GO EXEC sp_rename 'dbo.ShortListDB_Gecis_Sil', 'ShortListDB'; GO -- bosa cikaralin eski orjinal tablo ya silinir ya da bir sure tutulmak uzere tekrar adi degisitirilir. USE [KNetSubDB2] GO EXEC sp_rename 'dbo.ShortListDB_HEDE', 'ShortListDB_Gecis_Sil'; GO