USE [TestDb]
GO
ALTER DATABASE [TestDb] SET RECOVERY SIMPLE WITH NO_WAIT
DBCC SHRINKFILE([TestDb_Log], 1)
ALTER DATABASE [TestDb] SET RECOVERY FULL WITH NO_WAIT
GO
Where TestDB, is the database name, and TestDB_Log is the SQL Log file name.
USE [TestDb]
GO
ALTER DATABASE [TestDb] SET RECOVERY SIMPLE WITH NO_WAIT
DBCC SHRINKFILE([TestDb_Log], 1)
ALTER DATABASE [TestDb] SET RECOVERY FULL WITH NO_WAIT
GO
Where TestDB, is the database name, and TestDB_Log is the SQL Log file name.
After a migration of a database, the mapping of username is lost.
You can rejoin the username in database security with the “real” username with this commands:
EXEC sp_change_users_login 'Auto_Fix' , 'TheUserName';
Steps for chaning Collation:
/QUIET – Run it as a sillent installation
/action – We are running rebuilddatabase to change the server collation
/Instancename – withs instance do you want to change collation on.
/SAPPW -SA password for this instance
/SQLSYSADMINACCOUNTS – An administration account, normally the run you are running this from. The user should be administrator of the SQL Server
/SQLCollation – withs collation should you change to.
SQL Query:
SELECT @@version as 'server version'
Select SERVERPROPERTY('COLLATION') as 'server collation'
If you want to take a backup from Microsoft SQL Server management Studio, and get this error: Operating system error 5(error not found), then the problems is that the user running SQL Server services dosen’t have access to the destanation folder of you backup.
If you want to restore a Microsoft SQL database, from a fuld backup, and put some transaction log file into it. (This backup has backup by ahsay)
This is the why to do it:




RESTORE LOG Farma_test
FROM DISK = ‘F:\RestoreTest\2011-09-13(11-00-00)_LOG_RestoreTest_2011.bak’
WITH NORECOVERY
RESTORE LOG Farma_test
FROM DISK = ‘F:\RestoreTest\2011-09-13(12-00-00)_RestoreTest_2011.bak’
WITH NORECOVERY
sp_configure ‘show advanced options’,1
reconfigure with override
go
sp_configure ‘max server memory’, 4096
reconfigure with override
go
sp_configure ‘show advanced options’,1
reconfigure with override
go
sp_configure ‘max server memory’, 256
reconfigure with override
go
USE <databasename>
GO
DBCC SHRINKFILE(‘<logfilename-logical name>’, 1)
BACKUP LOG <databasename> WITH TRUNCATE_ONLY
DBCC SHRINKFILE(‘<logfilename-logical name>’, 1)
GO
Howto see active sessions in a mssql.
Its pretty easy just make a new query, and run sp_who or sp_who2.
sp_who shows whitch active sessions there are, and sp_who2 shows more information about the users.