Good script:
SELECT db_name(dbid) as DatabaseName, count(dbid) as NoOfConnections,
loginame as LoginName
FROM sys.sysprocesses
WHERE dbid > 0
GROUP BY dbid, loginame
The script can enumerate all databases on a SQL 2005-2008 r2 server and list active connection.
FROM: http://www.sqlservercurry.com/2008/03/how-to-see-active-connections-for-each.html
Showing posts with label SQL. Show all posts
Showing posts with label SQL. Show all posts
Tuesday, February 21, 2012
Friday, February 05, 2010
Cannot install SQL2008
Then I run install it give me in Setup Support Rules: "Restart Computer" - Status is not passed. Solution:
Clearing (but you can delete the key) the value in the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations fixed the issue.
(no reboot)
Tuesday, February 05, 2008
Move SQL 2005 system databases
Good article at http://www.sqlservercentral.com/articles/Administration/2605/# By Vince Iacoboni, 2006/09/26 with script. Just one problem you need to disconnect your SQL server from the newtwork and stop all additional SQL services as Reporting, Analysis, Search and so on, and stop WWW service. All of this should be done in order the script will be able to put SQL server in single user mode and move mssqlsystemresource database.
Wednesday, January 02, 2008
SQL 2005 Express backup
I found good article about it (http://www.brianmadden.com/content/article/How-to-Automate-the-Backup-of-a-SQL-Server-2005-Express-Data-Store). Here some information from this blog:
"For further SQL Server Express management options download and install SQL Server Management Studio Express . This is a free tool from Microsoft and will be used to create a script to backup your data store.
Once the tool is installed, launch Microsoft SQL Server Management Studio Express and connect to the CITRIX_METAFRAME instance.
Expand Databases and you will see the MF20 database. (This is the default name of the database that was created when creating the Presentation Server farm.)
Right click the MF20 database and select “Tasks Backup”. A dialog box appears allowing you to define different options such as what type of backup (full or differential) you want to do, backup destination etc. Configure the available options as desired then click the “Options” page on the left-hand column. Continue configuring options accordingly. For example, you may want to select “overwrite all existing backup sets.”
Once all desired options are set, select “Script Actions to File” and enter a desired file name, for example, “DatastoreBackup,” and specify the location where to save the file.
This creates a .SQL file which scripts the options you defined in the prior step
BACKUP DATABASE [MF20] TO DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\MF20.bak' WITH NOFORMAT, INIT, NAME = N'MF20-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10 GO
To test your .SQL file run the following from a command prompt.
sqlcmd -S .\CITRIX_METAFRAME -i "C:\\DatastoreBackup.sql"
If the MF20.bak file was created with the correct data and time stamp then you know your script works. By default the MF20.bak is located in C:\Program Files\Microsoft SQL Server\MSSQL\MSSQL\Backup. (This folder might be “MSSQL.1” or “MSSQL.x” depending on what else is on your server.)
Automating the Database Backup
You can automate the backup process by creating two Scheduled Tasks.
SQLCMD Scheduled Task
First, create a Scheduled Task to automate the .SQL script created above. Use the Scheduled Task Wizard and when asked to select a program browse to use browse to C:\Program Files\Microsoft SQL Server\90\Tools\binn\ SQLCMD.exe. Define the Schedule Task parameters accordingly and click “Finish”.
Go the properties of the newly created Scheduled Task and edit the Run command as such.
"C:\Program Files\Microsoft SQL Server\90\Tools\Binn\SQLCMD.EXE" -S .\CITRIX_METAFRAME -i "C:\Program Files\Microsoft SQL Server\DatastoreBackup.sql" "
Actually you can backup in such way any sql 2005 express database, but after creating the script you need to create a batch file and put it on schedule. It is good practice point the backup on network share with enabled shadow option (it give you opportunity to restore from different backup sets without creating additional scripts).
It is good practise to check SQL servers names with command:
sqlcmd -L
If the server does not have sqlcmd.exe utility it can be downloaded from http://www.microsoft.com/downloads/details.aspx?FamilyID=d09c1d60-a13c-4479-9b91-9e8b9d835cdc&displaylang=en as a part of Feature Pack for Microsoft SQL Server 2005, but you should download the native client too. Same way you can backup SQL 2000 databases.
"For further SQL Server Express management options download and install SQL Server Management Studio Express . This is a free tool from Microsoft and will be used to create a script to backup your data store.
Once the tool is installed, launch Microsoft SQL Server Management Studio Express and connect to the CITRIX_METAFRAME instance.
Expand Databases and you will see the MF20 database. (This is the default name of the database that was created when creating the Presentation Server farm.)
Right click the MF20 database and select “Tasks Backup”. A dialog box appears allowing you to define different options such as what type of backup (full or differential) you want to do, backup destination etc. Configure the available options as desired then click the “Options” page on the left-hand column. Continue configuring options accordingly. For example, you may want to select “overwrite all existing backup sets.”
Once all desired options are set, select “Script Actions to File” and enter a desired file name, for example, “DatastoreBackup,” and specify the location where to save the file.
This creates a .SQL file which scripts the options you defined in the prior step
BACKUP DATABASE [MF20] TO DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\MF20.bak' WITH NOFORMAT, INIT, NAME = N'MF20-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10 GO
To test your .SQL file run the following from a command prompt.
sqlcmd -S .\CITRIX_METAFRAME -i "C:\
Automating the Database Backup
You can automate the backup process by creating two Scheduled Tasks.
SQLCMD Scheduled Task
First, create a Scheduled Task to automate the .SQL script created above. Use the Scheduled Task Wizard and when asked to select a program browse to use browse to C:\Program Files\Microsoft SQL Server\90\Tools\binn\ SQLCMD.exe. Define the Schedule Task parameters accordingly and click “Finish”.
Go the properties of the newly created Scheduled Task and edit the Run command as such.
"C:\Program Files\Microsoft SQL Server\90\Tools\Binn\SQLCMD.EXE" -S .\CITRIX_METAFRAME -i "C:\Program Files\Microsoft SQL Server\DatastoreBackup.sql" "
Actually you can backup in such way any sql 2005 express database, but after creating the script you need to create a batch file and put it on schedule. It is good practice point the backup on network share with enabled shadow option (it give you opportunity to restore from different backup sets without creating additional scripts).
It is good practise to check SQL servers names with command:
sqlcmd -L
If the server does not have sqlcmd.exe utility it can be downloaded from http://www.microsoft.com/downloads/details.aspx?FamilyID=d09c1d60-a13c-4479-9b91-9e8b9d835cdc&displaylang=en as a part of Feature Pack for Microsoft SQL Server 2005, but you should download the native client too. Same way you can backup SQL 2000 databases.
Wednesday, September 27, 2006
SQL 2005 replication with SQL Express.
Good article:
http://msdn2.microsoft.com/en-us/library/ms165700.aspx
SQL Server 2005 Merge Replication
http://softwarex-nz.blogspot.com/2006/04/sql-server-2005-merge-replication.html
http://msdn2.microsoft.com/en-us/library/ms165700.aspx
SQL Server 2005 Merge Replication
http://softwarex-nz.blogspot.com/2006/04/sql-server-2005-merge-replication.html
Subscribe to:
Posts (Atom)