Monday, May 26, 2014

Add new article in transactional replication in SQL Server 2012

Add new article in transactional replication in SQL Server 2012
Creating replication is one thing and maintaining it is a different yet equally important thing. Over the time, you might add or remove some objects in your primary database and hope the same for your replication database and this article comes into the picture when you need to add some more object from primary (Publication) database to replicated (subscriber) database.



Step 1 :













Step 2:






step 3 :


Sunday, May 25, 2014

Copy And Paste From SQL Server Management Studio 2012 New Line Issue Into Excel

select REPLACE(REPLACE(col, CHAR(13), ''), CHAR(10), ' ')




for eg : 

OrderStatus=REPLACE(REPLACE(cast(OrderTxtStatus as varchar(500)), CHAR(13), ''), CHAR(10), ' ')

Monday, May 12, 2014

sql server Replication and Move Database Files mdf and ldf to Another Location


Step 1 :  Stop log agent in primary DB replication located

Step 2 : Open Read or secondary DB , new query window --->USE MASTER;

Step 3 :  Run 

-- Take database in single user mode -- if you are facing errors
-- This may terminate your active transactions for database
ALTER DATABASE db_read
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE;
GO

Step 4 : -- Detach DB
EXEC MASTER.dbo.sp_detach_db @dbname = N'db_read'
GO

Step 5 : Manually move the mdf and ldf Files from Loc1 to Loc 2

Step 6 : -- Re-Attached DB
CREATE DATABASE [db_read] ON
( FILENAME = N'D:\Program Files\Microsoft SQL Server\MSSQL\DATA\db_read.mdf' ),
( FILENAME = N'D:\Program Files\Microsoft SQL Server\MSSQL\DATA\db_read_log.ldf' )
FOR ATTACH
GO

Step 7 : start the log agent in primary DB