Backtrack:  
 
showing posts tagged with 'sqlserver'
1 · 2
 
edited by on May 26th 2015, at 16:17
Two methods of truncating the transaction logs for a database for SQL Server 2008 or newer:

Perform a backup to the nul device, essentially a "black hole":

BACKUP LOG [databaseName] TO DISK = 'nul:'

Temporarily set the recovery model to SIMPLE, then shrink the transaction log:

ALTER DATABASE databaseName SET RECOVERY SIMPLEDBCC SHRINKFILE('databaseName_log', 0, TRUNCATEONLY)ALTER DATABASE databaseName SET RECOVERY FULL

WARNING: truncating the transaction log without a backup may result in data loss in case of a database failure!

EDIT (26/05/2015):

You could attempt the backup/shrink routine without changing the recovery mode, but this will most likely onl  ...
edited by on May 26th 2015, at 14:17
You can move the tempdb of a SQL Server instance to another location using T-SQL, but this requires a little bit of downtime: setting a new location will only take effect after a restart of the SQL Server instance.

First, retrieve the tempdb's current location and logical name:

Use tempdbGOSELECT name,filename FROM sys.sysfilesGO

This should give you two entries: one for the actual database, and one for the transaction log of tempdb. Now that we have the location and logical name, we can change it:

ALTER DATABASE tempdb MODIFY FILE (NAME = tempdev, FILENAME = 'T:\newdir\tempdb.mdf');GOALTER DATABASE tempdb MODIFY FILE (NAME = templog, FILENAME = 'T:\newdir\templog.ldf');GO

Replace the p  ...
edited by on May 26th 2015, at 14:05

If, when attempting to start SQL Server instance, you get an error 1814, this means there's a problem with the tempdb database. Either it can't be created because the disk or volume is not accessible for writing (i.e. a security permission problem), or the volume on which the tempdb resides does not have enough space available. If the latter is the problem, you'll need at least 2 MB of free space for tempdb to be created.

edited by on May 22nd 2015, at 11:26
You can perform resource configuration for SQL Server Analysis Services (SSAS) through SQL Server Management Studio (SSMS). Simply connect to the SSAS (select Microsoft Analysis Server as server type and connect to the instance name). Using SSMS allows to change only a limited number of common and advanced parameters. Many of the very advanced parameters (usually those that require a restart of SSAS) can only be configured through a file called msmdsvr.ini.

The INI-file msmdsvr.ini, by default located in %PROGRAMFILES%\Microsoft SQL Server\<ssas-instance-name>\Config and in fact is an XML-file, allows you to configure both common and advanced parameters of SSAS. By default, the file i  ...
edited by on May 21st 2015, at 16:30
After running complex queries that use the tempdb of a SQL Server instance, it may become necessary to shrink the database again. However, when running the shrink operation on the tempdb, it can result in the database not shrinking at all, even when the used space is minimal.

The reason for this is most likely that the clearance of the tempdb is still in cache and not flushed to disk. You need to flush the changes to disk first, after which you will be able to shrink the tempdb. Do note that flushing will most likely impact database performance, so use with caution. Also, the tempdb will not shrink beyond the initial size, configured in the file group.

DBCC FREESYSTEMCACHE('ALL')USE [tempd  ...
edited by on May 20th 2015, at 16:18

You can retrieve a list of stored procedures in a SQL Server database through T-SQL by querying the built-in information_schema partition.

SELECT * 
FROM db_name.information_schema.routines 
WHERE routine_type = 'PROCEDURE'

Replace db_name with the name of the database you wish to retrieve the list of stored procedures. You can adjust the WHERE-clause even more to get a more narrow list.

You can also do this with the master database which will return all (system and non-system) stored procedures.

edited by on May 19th 2015, at 16:10

Probably MSSQL 101, but this is how to quickly retrieve the structure of a table:

EXEC sp_help tbl_name
GO

tbl_name is the name of the table.

edited by on May 19th 2015, at 16:07
When attempting to run an online integrity check, or a backup on a large database (i.e. large data files), you may run into this error:

Error: 5123, Severity: 16, State: 1.CREATE FILE encountered operating system error 665(failed to retrieve text for this error. Reason: 15105) while attempting to open or create the physical file 'D:\MSSQL\Data\db.mdf:MSSQL_DBCC9'.

Further investigation reveals that the error 665 is in fact: The requested operation could not be completed due to a file system limitation.

Backup and consistency (dbcc) check operations requires the creation of a database snapshot. These snapshots are created as sparse files, which only works on NTFS (not ReFS), but has some l  ...
by on January 1st 1970, at 01:00
Provided you still have administrative access to the server itself, and the server is running in mixed mode (i.e. you can actually use local SQL logins), you can perform the steps below to reset the password. Note that this will result in some downtime as the SQL Server service will have to be restarted in single user mode.

First, determine the service name (can be done via services.msc): if it is the default instance, it's usually called MSSQLSERVER. If an instance name was specified, it is usually MSSQLSERVER$instance-name. E.g. if the instance is called MYSWEETAPP, the service name would be MSSQLSERVER$MYSWEETAPP.

Open an administrative (elevated) command prompt or Powershell:

First, s  ...
1 · 2
 
showing posts tagged with 'sqlserver'
 
 
« December 2024»
SunMonTueWedThuFriSat
1234567
891011121314
15161718192021
22232425262728
293031    
 
Links
 
Quote
« Debating Windows vs. Linux vs. Mac is pointless: they all have their merits and flaws, and it ultimately comes to down to personal preference. »
Me