Quantcast
Channel: SQL Server Database Engine forum
Viewing all 12644 articles
Browse latest View live

Reverse Logshipping to avoid huge downtime !

$
0
0
Hi Experts,

Need your help,we are doing a very large MSSQL database migration from one DC to another DC.

We have configured log shipping to promote less downtime during the migration. Our application team requesting for 2-3 testings for which they need DB to be online in secondary server with latest available data (They are okay to replicate this testing data to primary database)

Here is my question:

Assume A as Primary server and B as secondary server 

During application testing, reverse log shipping can be done two times i.e B to A and A to B  (goal is to make primary as primary and secondary as secondary).

please also advise if it raises any challenges during this reverse log shipping ? Thank you 

Regards,
Naren Poosa



high transactions on msdb,tempdb

$
0
0

Hi all,

I've noticed a large increase of transactions on msdb and tempdb on a particular sql instance.

Any ideas on what to check to determine the reason for the large number of transactions?  I don't see much change in top queries, top sessions and all users don't have a default database set to msdb or tempdb.

instancename

duration

trnxPerDuration

_Total

23

15342744

msdb

23

8210456

tempdb

23

5117195

******DB

23

1113444

****DB

23

436318

***GDB

23

267956

master

23

113485

****GDB

23

30527

rdsadmin

23

20386

****DB

23

13269

********DB

23

13266

******

23

4625

model

23

1159

mssqlsystemresource

23

658

Password of Restore Master Key

$
0
0

I am reading this Microsoft article Restore Master Key , and I would like to ask about the password of the query.

RESTORE MASTER KEY FROM FILE = 'path_to_file' DECRYPTION BY PASSWORD = 'password1' ENCRYPTION BY PASSWORD = 'password2'

(Q1) The password for decryption above is when you created Database Master Key or backup of Database Master Key? Or should they be the same password both?

     (a) The query for creating Database Master Key

CREATE MASTER KEY 
ENCRYPTION BY PASSWORD ='Password_Of_DMK'

     (b) The query for backing up Database Master Key 

BACKUP MASTER KEY TO FILE = 'path_to_backup_of_DMK'   
ENCRYPTION BY PASSWORD = 'password_of_backup_of_DMK'

(Q2) The password2 in the first query at top is you can set new DMK password to encrypt the database under the new instance where you are restoring this DMK from the backup of the DMK that you took from previous location. (Please correct me if my understanding is not right..)

shrinking db

$
0
0

Hi,
My databse size aroung 1tb.
Instead of selecting the file to shrink by mistake i did for whole db..Now it is running. I am doubting to stop the process. On this db transactional replication is goingon. In the replication monitor everything running excellent. no latency.
How much time it will take shrink 1tb database?
actually i was getting error as below.
The transaction log for database 'database_name' is full due to 'XTP_CHECKPOINT'.
So thought of shrinking the log file. But did it for full db. It is a production db. Now i am scaring how much time it will take. Will it currupt if i kill shrinking process.. 
What i need to take care?Please guide me.Sad 

Thanks.


pols

i want to take a back up the large data bases tables, but data is not old data, it need to be accessible by the application, what i the best approach,

$
0
0
i want to take a back up the large data bases tables, but data is not old data, it need to be accessible by the application, what i the best approach,

Allways on secondary is not in sync

$
0
0

Hi,

We configured SQL 2014 Allways on availability in 3 servers. A-Primary(read,write),B-Secondary(Read),C-DRnode(Readable secondary we set to No.) we set Properties- Manual failover for all. 

And as per application we configured Transactional replication for db-XYZ from A to B .

Midnight our primary server  A completely went down for 4 hours. Now the server is up. But we found that The Data is not sync and replication also failed. Ofcourse now server B is Primary. And the secondary is server A(db is not in sync).  The DRnode db is also in Sync state.No complaints with DRnode and Primary server. (In AG properties - Now Primary is B the availability mode is Synchronous and the Secondary which is B server is Asynchronous and DRNode is Asynchronous).

When i checked the replication the error msg is db is not accessible for queries. and In ALLWayson Dashboard with warning beow:

"At least one availability database on this availability replica has an unhealthy data synchronization state. If this is an asynchronous-commit availability replica, all availability databases should be in the SYNCHRONIZING state. If this is a synchronous-commit availability replica, all availability databases should be in the SYNCHRONIZED state."

except only one db-XYZ all other dbs are in sync. this db size is around 1 TB. Which the same db is in tran replication too.

How to bring back this db-XYZ to normal sync. and replication should work normally?

Please guide me. this is very critical production issue and need to bring to sync.

I tried " ALTER DATABASE [XYZ] SET HADR RESUME" -No result.

I‌ tried "select * from sys.dm_hadr_database_replica_states" below are results:
l‌og_send_que_size=null,log_send-size=0,suspend_reason_description=suspend_from_revalidation and suspend_reason=7
D‌o i need to check anything?

Thought of removing XYZ db from AG and add freshly but my Sr DBA tells not a feasible option.

We just started taking FULL Backup of the XYZ. It willl take 3 hrs to finish. By this time i need to get some solution to resolve this issue.

Please help.

Thanks.


pols



SQL question

$
0
0
We are planning to migrate the databases from datacenter1 to datacenter2. Some of the source databases in datacenter1 are in SQL 2008 & rest in SQL 2012. But the databases will get migrated to SQL 2016 in datacenter2. The databases in datacenter2 should be on Alwayson High Availability Cluster after migration. What's the best way of migrating the databases to datacenter2 with minimum downtime. Looking into options of keeping the databases in sync between the 2 datacenters using logshipping or mirroring. But not sure if the target db in datacenter2 can still participate in Alwayson cluster while being in sync between the 2 datacenters. Any ideas? Thanks.  

sqldev

Help required on MS SQL query

$
0
0

The below query returns row count that are created for every 30 minutes. The below query displays slots only where row count exist (the below query not displays slots where row count is 0). 

I need to display all slots with row count - even if row count is 0 (from 00:00:10.000 to 23:59:10.000). Can you please suggest on which line and what logic i need to add in below query to display below slots with row count.

WITH Data
AS ( SELECT T.* ,
            DATEADD(MINUTE, DATEDIFF(MINUTE, CAST(T.CreatedOn AS DATE), T.CreatedOn) / 30 * 30, CAST(CAST(T.CreatedOn AS DATE) AS DATETIME)) AS BucketStart,
            DATEADD(MINUTE, 30 + DATEDIFF(MINUTE, CAST(T.CreatedOn AS DATE), T.CreatedOn) / 30 * 30, CAST(CAST(T.CreatedOn AS DATE) AS DATETIME)) AS BucketEnd
     FROM   IB T )

SELECT   CONVERT(VARCHAR(20), D.BucketStart, 120) + ' - ' + CONVERT(VARCHAR(10), BucketEnd, 108) AS [DateTime],
         COUNT(*) As [Total Case Count]
FROM     Data D      
WHERE name = 'MBO' 
AND CreatedOn between '2019-02-04 00:00:10.000' and '2019-02-04 23:59:10.000'
GROUP BY D.BucketStart, BucketEnd
ORDER BY D.BucketStart;

These the slots I am looking to show, I am looking just one day data of reported.

DateTime RowCount

========================================

00:00:10 - 00:30:10 1000:30:10 - 01:00:10 2101:00:10 - 01:30:10 001:30:10 - 02:00:10 10002:00:10 - 02:30:10 5102:30:10 - 03:00:10 003:00:10 - 03:30:10 003:30:10 - 04:00:10 004:00:10 - 04:30:10 204:30:10 - 05:00:10 105:00:10 - 05:30:10 005:30:10 - 06:00:10 906:00:10 - 06:30:10 006:30:10 - 07:00:10 007:00:10 - 07:30:10 007:30:10 - 08:00:10 008:00:10 - 08:30:10 008:30:10 - 09:00:10 1209:00:10 - 09:30:10 109:30:10 - 10:00:10 110:00:10 - 10:30:10 110:30:10 - 11:00:10 111:00:10 - 11:30:10 111:30:10 - 12:00:10 012:00:10 - 12:30:10 012:30:10 - 13:00:10 513:00:10 - 13:30:10 313:30:10 - 14:00:10 114:00:10 - 14:30:10 014:30:10 - 15:00:10 100015:00:10 - 15:30:10 115:30:10 - 16:00:10 016:00:10 - 16:30:10 016:30:10 - 17:00:10 117:00:10 - 17:30:10 117:30:10 - 18:00:10 2318:00:10 - 18:30:10 2118:30:10 - 19:00:10 2119:00:10 - 19:30:10 319:30:10 - 20:00:10 23420:00:10 - 20:30:10 220:30:10 - 21:00:10 021:00:10 - 21:30:10 021:30:10 - 22:00:10 422:00:10 - 22:30:10 1522:30:10 - 23:00:10 023:00:10 - 23:30:10 1


TSQL query syntax error

$
0
0

Hi All,

I am getting below syntax error. Please help me to fix below syntax error.

Msg 102, Level 15, State 1, Line 14
Incorrect syntax near ')'.

Line 14 is: )

with data as (
        select
              cast(CreatedOn as date) dt
            , datepart(hour,CreatedOn)  h
            , round(datepart(minute,CreatedOn) / 30,0) * 30 m
            , count(*) cnt
        from IB                 
        WHERE owneridname = 'MBO' 
        AND CreatedOn >= '20190204' and CreatedOn < '20190205' 
        group by
              cast(CreatedOn as date)
            , datepart(hour,CreatedOn)
            , round(datepart(minute,CreatedOn) / 30,0) * 30
    )

Enforce Password Policy Configuration

$
0
0

As long as I read out the following article, If I checked ON of "Enforce password expiration" of SQL login account, it will follows to Local Security Policy setting on the server.

SQL Server Login Properties to Enforce Password Policies and Expiration

Is there any way to set up separately SQL account and OS account? I would like to set up maximum password age of SQL login account to 365 days, and local account for the server(=OS) to 60 days..  

Not able to import XLSX file into Sql server

$
0
0

While importing xlsx file in sql server I am getting the below error:


    The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine. (System.Data).


I have already installed `AccessDatabaseEngine_X64`. 


what settings should I check more?

I am using WIN 10 64 bit , SQL server 2016 , Microsoft office 365 pro plus 64 bit

Connection not using kerberos

$
0
0

I am using SQL server 2016 and in sys.dm_exec_connections and all the auth_schm are NLTM. and the protocal are

the server name is SQL16_07 port 40000   default instance.

I have check SPN is registered in AD,

setspn -L mylab\dev16_sql_svc


        MSSQLSvc/SQL16-07.mylab.com:40000
        MSSQLSvc/SQL16-07.mylab.com

and I am using windows authen. Kerberos delegation already set in AD.

What are SMK backup and database certficate for?

$
0
0

As reading this Microsoft articles below, I am getting understand on the structure of Service Master Key(SMK) and Database Master Key(DMK), but it is not perfect yet. Can I ask a couple of things about them?

Backup Service Master Key

Backup a Database Master Key

TDE

(Q1) What is backup of SMK for? 

I know backup of DMK is required when I move the database to new instance, but how about backup of SMK? I think SMK is automatically generated when you install SQL server, so new SMK is already sat up in new instance, I think.

(Q2) What is database certificate for? 

I am still not sure what the certificate with the query below is required for?

use master;

Create Certificate <Name_Of_Certificate> With Subject = '<Subject_Of_Certificate>';

I is my understanding that database certificate is required only if you need to set up TDE on your database. and DMK encrypt database, but TDE is different kind of encryption with DMK encryption, and it is much higher security, and if you would like to set up TDE on your database, you need to create DMK and the certificate of master database, then execute the query below for TDE configuration to your database.

Create Database Encryption Key With Algorithm = <AES_256>
Encryption By Server Certificate <Name_Of_Server_Certificate>
(Q3) Should I take a backup of the certificate if I create it? If TDE is not required to my database, Is it okay not to create the certificate? 
 

 


How to find out index fragmentation level for large db

$
0
0

hi folks: 

 I tried the following query on small db and all got results within a few seconds. however, this DB is giving me trouble by showing me the PAGEIOLATCH_SH wait type. DB itself has over 300G on SQL 2012 Ent.

SELECT OBJECT_NAME(ind.OBJECT_ID) AS TableName, indexstats.page_count,

ind.name AS IndexName, indexstats.index_type_desc AS IndexType, 
indexstats.avg_fragmentation_in_percent 
FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, NULL) indexstats 
INNER JOIN sys.indexes ind  
ON ind.object_id = indexstats.object_id 
AND ind.index_id = indexstats.index_id 
WHERE indexstats.avg_fragmentation_in_percent > 10 and indexstats.page_count >1000
ORDER BY indexstats.avg_fragmentation_in_percent DESC

Is there any other way to find out index fragmentation info for relatively large db. 

Thanks

 HS


--Currently using Reporting Service 2000; Visual Studio .NET 2003; Visual Source Safe SSIS 2008 SSAS 2008, SVN --


Time for DDL execution for an existing table

$
0
0

Dear All,

We have SQL server 2016 Standard edition . I am currently altering a table structure as below :-

ALTER TABLE XB_TRANSACTION_DETAILS_DAILY_DATA
  ALTER COLUMN  LCID varchar(100) not null;

Currently LCID column is set to null and varchar(max)

Table contains almost 50 crores records, how long will this command will take .

Any idea will be highly appreciated .

Best Regards,
Sandy


Migrating SQL server 2005 databases to SQL server 2016

$
0
0

Hi All,

I have been migrating sql server 2005 databases to sql server 2016 using backup and restore. I have been successful so far with some smaller size DBs.

I am currently trying to copy the backup file of ~60GB and then restore it.

While restoring through GUI it does not show any backupsets. So i ran below script

Restore verifyOnly from disk='G:\SQL server 2016\<db_name>.bak'

It runs into below error

"Msg 4038, Level 16, State 1, Line 6
Cannot find file ID 1 on device 'G:\SQL server 2016\<db_name>.bak'.
Msg 3013, Level 16, State 1, Line 6
VERIFY DATABASE is terminating abnormally."

Is it just that the backup file is getting corrupted every time I copy it to target server?

Or there is some version compatibility issue from 2005-->2016. Although i was able to restore 2 other DBs successfully from same source/target server.

Historical data with Change Tracking

$
0
0

Hi,

I'm a bit puzzled by the documentation claiming that Change Tracking does not store historical data (use CDC instead).  Being new to this I did an experiment, and with the below simple code, I see all of the previous values (each as a "delete" change).

Is the documentation wrong, or am I missing something?

create table dbo.Test_CT
(
	id int,
	PersonName varchar(15)
	constraint PK primary key (id, PersonName)
)

insert into dbo.Test_CT
select 1, 'John'

--ALTER DATABASE MyDB  
--SET CHANGE_TRACKING = ON  
--(CHANGE_RETENTION = 2 DAYS, AUTO_CLEANUP = ON)

ALTER TABLE dbo.Test_CT
ENABLE CHANGE_TRACKING WITH (TRACK_COLUMNS_UPDATED = ON)

update dbo.Test_CT set PersonName = 'John Doe' 
update dbo.Test_CT set PersonName = 'John Doe 2'
update dbo.Test_CT set PersonName = 'John Doe 3'
update dbo.Test_CT set PersonName = 'John Doe 4' 
update dbo.Test_CT set PersonName = 'John Doe 5'

SELECT * FROM CHANGETABLE (CHANGES test_CT,0) as CT ORDER BY SYS_CHANGE_VERSION


SQL Database Mail - Masquerading Domain and FQDN

$
0
0

I am successfully using SQL Database mail but would like to change the server name that is being used when sending mail to the SMTP server.

As an example:

Received: from unknown (HELO ServerName) ([111.111.111.111])

I would like to provide a FQDN for the text in bold above. I believe that was done in MS SMTP with the Masquerading Domain value and the FQDN value that could be set by an administrator.

How can this be done SQL Database Mail?

Thank you


Microsoft always on availability cluster failing occasionally.

$
0
0

I have three 3 node clusters created in my environment.  There are two synchronous nodes at one data center and one asynchronous node at another data center.  Each node has its own disks so there's no shared storage.  Occasionally maybe once a month, my test cluster becomes unavailable.  It won't ping and clients can't connect to the SQL cluster listener.  It happened again this morning and was unavailable for about a half hour, then without changing anything, it came back to life.  In the past, I was able to initiate a manual failover/failback and it would come back right away but I'd like to find out why this is happening in the first place.  This does not happen with the other clusters.

There are no cluster errors registered in event viewer.  No nodes fail, I can connect to each one individually.  The cluster name does not ping and neither does the SQL listener, so that leads me to believe it is a Microsoft clustering problem and probably not a SQL issue.

I did a get-clusterlog and have been pouring through it.   I do see DBG messages like:


[Verbose] 000009ac.00001678::2019/02/12-09:46:49.619 DBG   [GEM] Node 1: GEM Id 3565 has been ack'ed by every node. Unacknowledged Message Count = 5
[Verbose] 000009ac.00001678::2019/02/12-09:46:49.619 DBG   [GEM] Node 1: GEM Id 3566 has been ack'ed by every node. Unacknowledged Message Count = 4
[Verbose] 000009ac.00001678::2019/02/12-09:46:49.621 DBG   [GEM] Node 1: GEM Id 3567 has been ack'ed by every node. Unacknowledged Message Count = 3
[Verbose] 000009ac.00001678::2019/02/12-09:46:49.621 DBG   [GEM] Node 1: GEM Id 3568 has been ack'ed by every node. Unacknowledged Message Count = 2
[Verbose] 000009ac.00001678::2019/02/12-09:46:49.621 DBG   [GEM] Node 1: GEM Id 3569 has been ack'ed by every node. Unacknowledged Message Count = 1
[Verbose] 000009ac.00001678::2019/02/12-09:46:49.621 DBG   [GEM] Node 1: GEM Id 3570 has been ack'ed by every node. Unacknowledged Message Count = 0

Around the time it came back up.

Also entries like this often - the possible owners list size is 0 message is interesting.


[Verbose] 00001a40.00002920::2019/02/12-09:48:17.162 INFO  [RES] Distributed Network Name <CAUSACSQvu8>: Netname received Refresh clones message
[Verbose] 00001a40.00002920::2019/02/12-09:48:17.162 INFO  [RES] Distributed Network Name <CAUSACSQvu8>:Possible owners list size is 0
[Verbose] 00001a40.000007d0::2019/02/12-09:48:17.165 INFO  [RES] Network Name: Agent: InitializeModule, Trying to initialize Module(ad4aa780-67db-41df-977e-35ef8ac4be5f,Client) when there is one already in Initialized/Idle state
[Verbose] 00001a40.00002920::2019/02/12-09:48:17.165 INFO  [RES] Distributed Network Name <CAUSACSQvu8>: StartupClone - Client module already exists.
[Verbose] 00001a40.000007d0::2019/02/12-09:48:17.165 INFO  [RES] Distributed Network Name <CAUSACSQvu8>: Client: Synching with slow operation

I don't see a cause and effect relationship when this fails so I can't trigger it.  It's like chasing a ghost.  If anyone has a place to start looking, I'd appreciate it.

HEAP table huge fragmentation reduction issue

$
0
0

hi folks:

 I have several heap tables with around 99% fragmentation level. I understand that best solution is to create a cluster index and stay there but I have to go for the temp fix for the time being. 

Temp fix are either alter table xxxxx rebuild or create a cluster index and immediately drop it. 

However, I tried alter table rebuild a few times , the avg_fragmentation_in_percent initially dropped but after a few rounds, 

it actually rose back? 

Also I tried to create a cluster index and check the fragmentation , it is gone totally. However after I dropped the cluster index and check sys.dm-db-index_physical_stats(), the fragmentation level is back to the same old. 

Did I do something wrong ? 

cheers

 HS


--Currently using Reporting Service 2000; Visual Studio .NET 2003; Visual Source Safe SSIS 2008 SSAS 2008, SVN --

Viewing all 12644 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>