Dave
SQL Server EE Licensing Question
DB Status restoring, shutdown
Hi,
Anybody got any ideas why a DB in high safety and auto failover mode would have a mirror db status of "restoring, shutdown"?
SQL server 2008 10.0.2531.0
Rgds
Monitor SQL Database mirroring using powershell script
I am trying use the below powershell script to monitor SQL Database mirroring. The motive here is to determine if there are databases which are in "Disconnected" or "Suspended" mode.
I am running the script on the Principal Server:
$returnStateOK = 0
$returnStateWarning = 1
$returnStateCritical = 2
$returnStateUnknown = 3
$NagiosStatus = ""
# Load SMO extension
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null;
# Servers to check
$sqlservers = @("$env:computername");
foreach($server in $sqlservers)
{
$srv = New-Object "Microsoft.SqlServer.Management.Smo.Server" $server;
# Get mirrored databases
$databases = $srv.Databases | Where-Object {$_.IsMirroringEnabled -eq $true -and $_.MirroringStatus -eq "Suspended" -or $_.MirroringStatus -eq "Synchronizing" -or $_.MirroringStatus -eq "Disconnected" -or $_.MirroringStatus -eq "None" -and $_.Name -ne "Master" -and $_.Name -ne "model" -and $_.Name -ne "msdb" -and $_.Name -ne "tempdb"};
if ($databases -ne $null)
{
$databases | Select-Object -Property Name, MirroringStatus | Format-Table -AutoSize;
exit $returnStateCritical
} Else {
Write-Host "All Databaes are Mirrored"
exit $returnStateOK
}
}
I have Suspended few databases for testing purpose but when I run the above script the output says "All Databaes are Mirrored"
If I make changes to $database and use it below i.e. I am changing the AND operator to OR after "$_.IsMirroringEnabled -eq $true"
$databases = $srv.Databases | Where-Object {$_.IsMirroringEnabled -eq $true -or $_.MirroringStatus -eq "Suspended" -or $_.MirroringStatus -eq "Synchronizing" -or $_.MirroringStatus -eq "Disconnected" -or $_.MirroringStatus -eq "None" -and $_.Name -ne "Master" -and $_.Name -ne "model" -and $_.Name -ne "msdb" -and $_.Name -ne "tempdb"};
I get the below output:
Name MirroringStatus
---- ---------------
DB1 Synchronized
DB2 Synchronized
DB3 Synchronized
DB4 Suspended
DB5 Suspended
DB6 Suspended
DB7 Synchronized
DB8 Synchronized
I only want the databases which are Suspended or Disconnected to be listed.
SQL Always on
Hi
I have server with sql server 2012 I want to add another node and create sql always on .
what is the steps shall i follow .
Thnaks
MCP MCSA MCSE MCT MCTS CCNA
Sql Server Transaction Log Backup Fails
I have a Sql Server 2008 Standard version. Mirroring is set up on the server in full safety mode. Its been working fine till today. The transaction log back-up fails every-time with an error
"Error: 2014-09-25 08:34:33.17 Code: 0xC002F210 Source: JuneDB Log Backup Execute SQL Task
Description: Executing the query "BACKUP LOG [JuneDB] TO DISK = N'H:\BKs\Hou..." failed with the following error: "Read on "E:\LDFs\JuneDB.ldf" failed: 1(Incorrect function.)
BACKUP LOG is terminating abnormally.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly"
I am not able to identify why reading the log file is erroring out. How am I supposed to proceed on this issue.
Things I tried
- Ran DBCC CHECKDB([JuneDB]) WITH NO_INFOMSGS returned no error messages
- Ran a query to take transaction backup instead of using a Maintenance plan. It gave same error
Update I just noticed at 4:30 AM we ran a maintenance plan to rebuild all indexes. Looking at the error log, I started getting errors for Transaction log backups after 4:30 Am. I am not sure how rebuild indexes could possibly cause the transaction log backups to fail but they sure seem related
SQl server log shipping retention
I have log shipping configured on SQL Server 2008 and the logs retention period is 72 hours . Does SQL Server provide such an option that if the copied logs are not restored on the secondary database (reason the restore job could be failing or any such scenario).
The purge job should not delete those trn files, that are yet to be restored .
To my understanding this is impossible could any one of you please inform me regarding this.
I will be grateful for your help.
sql procedure studAttendace report
i have table StudAttendance
id cardid intime outtime updtime std div
1123456789 2014-09-03 19:10 2014-09-03 23:10 2014-03-09 20:01 1 1
2123456788
2014-09-08 19:10 2014-09-03 23:10 2014-03-09 20:01 1 1
3123456785
2014-03-01 19:12 2014-03-09 23:30 2014-03-09 20:01 1 2
cardid is unique value of each student
intime is student insert school time and outtime is went time
updtime is bulk insert time .txt file to StudAttendance time
I have to design report ssrs so need sql procedure. ssrs design is below
studName CrdID 1 2 3 4 5 6 7 8 ..........31
name1 123456788 p p p A p p p p......... p
name2 123456785 A p p p p p p p .........p
.
.
So plz help
BACKUP failed to complete the command BACKUP LOG
How to create a .mdf SQL Server database from a Data-Tier Application file that has data?
This is a noob question, though I do use SQL Server databases all the time with Entity Framework when I code in C# using Visual Studio 2013. The development environment is found below at [A]. I am trying to make a clone of a SQL Server 2008 R2 database (.mdf) that exists online. I can read, connect and work with this database in Visual Studio 2013, but I wish to make a local copy of the database, as an .MDF file. Somewhere in my notes I have a way of creating a local copy from an online database when using Visual Studio but I forgot how (it seems, reviewing my notes, that it deals with ADO.NET which is deprecated in Visual Studio 2013 these days, or so it seems). So I'm looking for another way. What I did was create (or export) a "Data-Tier Application File" from the online SQL Server database, with data, and it seems to have worked in that this Data-Tier Application file exists on my hard drive and seems to have data in it ("SQL Server Replication Snapshot" is the format it seems). It contains skeleton code to create a database, but when I tried to execute it with SQL Server 2014 Management Studio, I got a bunch of errors.
So my question is:
1) Can I somehow create a .MDF SQL Server Database from an Data-Tier Application file that has data? What tool do I use? I saw this link, http://social.technet.microsoft.com/wiki/contents/articles/2639.how-to-use-data-tier-application-import-and-export-with-a-windows-azure-sql-database.aspx and it relates to Azure, but is there a tool for C#Visual Studio 2013, standalone?
2) If there's an easy way to create a .mdf SQL Server Database file from an online file, within SQL Server Management Studio? I don't think so, since it would require Administrator permissions on the online server, which I don't have. I have permission to read, update, delete the online database file, but strangely not to download it (the service I use has a tool for backup, but not for download).
3) same question as 2), but for Visual Studio 2013? I don't think so, since I notice none of the templates even mentions ADO.NET anymore, but instead they go with Entity Framework. Using EF I can of course do anything I want with the online database (CRUD), but it remains online. Maybe there's a switch to make a local copy? I guess I could write a short program to suck all the data out of the online database and put it into a new, duplicate database having the same tables, that I create on my localhost, but my question here is if there's an easier way than this, maybe a tool or command I can run from inside Visual Studio?
Any advice on any of the above questions is appreciated.
Thank you,
Paul
[A] Microsoft Visual Studio Professional 2013
Version 12.0.21005.1 REL
Microsoft .NET Framework
Version 4.5.51641
Microsoft Web Developer Tools 2013 2.0.40926.0
SQL Server Data Tools 12.0.30919.1
Microsoft SQL Server Data Tools
Windows Azure Mobile Services Tools 1.0
Windows Azure Mobile Services Tools
Database mirroring
Hi All
We have a database mirroing with witnesses server.
We are planning to maintenance activitiy on these servers which requires server reboot.
I wanted to know the steps in which these servers should be rebooted. Should i remove witness server and add it back?
Can i start with witness server, principle server and then mirror server in order of reboot.
ThanksDifferent Drive Structure Between Principal and Mirror
We havea 2-node (active/active) cluster with four failover instances installed. We use a dedicated drive for data files, one for log files and one for tempdb per instance .Predicting that we will be adding more instances in the future, we realized that we would run out of drive letters to set up. We intend to switch over and use mounted volumes instead that way we only use 1 drive letter per instance and will be able to add many more failover instances in the future. However, seen as we have over 150 databases across all current instances, reconfiguring the cluster drive setup will require a lot of time and work and is not in the immediate plans for our team (me :( ). I need to mirror as many databases as possible, based on priority, to a DR server on a geographically remote location. Since this server isn't setup with SQLServer yet, I was wondering if it would be a good idea to have the DR server set up with mount volumes now and establish mirroring between our production environment and the DR server that way so that at least half the battle is won. I am aware that the best practice for mirroring is to have the same drive structure between the principal and mirror server, however it is not a requirement. The only example issue I have seen with this set up is when you add a data file to a database and the DDL statements get sent over to the mirror and will fail since the drive setup will not be the same. This is something I am willing to deal with since adding data files to our databases is not something we do often, or at all. As new databases are added and mirrored, the WITH MOVE clause of the RESTORE statement can be used to place the files in their correct location in the mirror server.
Other than this, are there any other things to consider for this kind of mirroring set up?
Leroy G. Brown
Sql Server Synchronization from Local Server to Web Server
All the day we are entering data in our local Sql server 2008 and at the evening time I want to synchronize my Webserver also, so How I can synchronize my database on the webserver from my local database. Please someone help in this regards, I will thankful to him, Thanks in Advance.
mirroring error
hai,
I tried to solve problem by
1) allowing sqlserver through windows firewalls.
2)giving sys admin permissions to all the users and in server logins also for accessing database.
3)before that I successfully restored in mirror with no recovery.
please help me how to solve this problem.
thanks.
how to bring principle server to offline in mirroring
hi, I configured mirroring and now intentionally I tried to bring the principle to offline. how can I do this?
help me..
checking latency in mirroring
hi,
how do you see latency? what are the causes of it in mirroring? how to over come from it?
please provide me a basic idea with any scenarios.
replication with push subscriptions
hi,
My replication is configured with push subscription, the data is replicated to subscriber server and unfortunately data was deleted at subscriber and now the subscriber needs that data instantly.so how can subscriber will get data?
SQL Server EE Licensing Question
Dave
DB Status restoring, shutdown
Hi,
Anybody got any ideas why a DB in high safety and auto failover mode would have a mirror db status of "restoring, shutdown"?
SQL server 2008 10.0.2531.0
Rgds
Monitor SQL Database mirroring using powershell script
I am trying use the below powershell script to monitor SQL Database mirroring. The motive here is to determine if there are databases which are in "Disconnected" or "Suspended" mode.
I am running the script on the Principal Server:
$returnStateOK = 0
$returnStateWarning = 1
$returnStateCritical = 2
$returnStateUnknown = 3
$NagiosStatus = ""
# Load SMO extension
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | Out-Null;
# Servers to check
$sqlservers = @("$env:computername");
foreach($server in $sqlservers)
{
$srv = New-Object "Microsoft.SqlServer.Management.Smo.Server" $server;
# Get mirrored databases
$databases = $srv.Databases | Where-Object {$_.IsMirroringEnabled -eq $true -and $_.MirroringStatus -eq "Suspended" -or $_.MirroringStatus -eq "Synchronizing" -or $_.MirroringStatus -eq "Disconnected" -or $_.MirroringStatus -eq "None" -and $_.Name -ne "Master" -and $_.Name -ne "model" -and $_.Name -ne "msdb" -and $_.Name -ne "tempdb"};
if ($databases -ne $null)
{
$databases | Select-Object -Property Name, MirroringStatus | Format-Table -AutoSize;
exit $returnStateCritical
} Else {
Write-Host "All Databaes are Mirrored"
exit $returnStateOK
}
}
I have Suspended few databases for testing purpose but when I run the above script the output says "All Databaes are Mirrored"
If I make changes to $database and use it below i.e. I am changing the AND operator to OR after "$_.IsMirroringEnabled -eq $true"
$databases = $srv.Databases | Where-Object {$_.IsMirroringEnabled -eq $true -or $_.MirroringStatus -eq "Suspended" -or $_.MirroringStatus -eq "Synchronizing" -or $_.MirroringStatus -eq "Disconnected" -or $_.MirroringStatus -eq "None" -and $_.Name -ne "Master" -and $_.Name -ne "model" -and $_.Name -ne "msdb" -and $_.Name -ne "tempdb"};
I get the below output:
Name MirroringStatus
---- ---------------
DB1 Synchronized
DB2 Synchronized
DB3 Synchronized
DB4 Suspended
DB5 Suspended
DB6 Suspended
DB7 Synchronized
DB8 Synchronized
I only want the databases which are Suspended or Disconnected to be listed.
Sql Server Transaction Log Backup Fails
I have a Sql Server 2008 Standard version. Mirroring is set up on the server in full safety mode. Its been working fine till today. The transaction log back-up fails every-time with an error
"Error: 2014-09-25 08:34:33.17 Code: 0xC002F210 Source: JuneDB Log Backup Execute SQL Task
Description: Executing the query "BACKUP LOG [JuneDB] TO DISK = N'H:\BKs\Hou..." failed with the following error: "Read on "E:\LDFs\JuneDB.ldf" failed: 1(Incorrect function.)
BACKUP LOG is terminating abnormally.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly"
I am not able to identify why reading the log file is erroring out. How am I supposed to proceed on this issue.
Things I tried
- Ran DBCC CHECKDB([JuneDB]) WITH NO_INFOMSGS returned no error messages
- Ran a query to take transaction backup instead of using a Maintenance plan. It gave same error
Update I just noticed at 4:30 AM we ran a maintenance plan to rebuild all indexes. Looking at the error log, I started getting errors for Transaction log backups after 4:30 Am. I am not sure how rebuild indexes could possibly cause the transaction log backups to fail but they sure seem related