Archive for the ‘SQL Server’ Category

Difference between delete and truncate

Delete: Whenever we are using delete from tablename, then automatically deleted data internally stored in buffer. We can get it back by using rollback command.

Differences between where and having clause

WHERE: Where clause is used to filter the data based on condition. Only rows that meets conditions contribute data to the result set. Filters rows Where clause is executed before group by clause. Use where clause, if there is no aggregate function in condition.

Table definition in SQL Server

If we want to see the table definition in SQL Server, then we can get using sp_help procedure. Syntax: sp_helptext [ @objname = ] ‘name’ [ , [ @columnname = ] computed_column_name ]

emp table script SQL Server

Standard emp table script for SQL Server 1) Create table structure 2) Insert data into emp table

Windows could not start the sql server on local computer

Generally we receive the following error message when we tried to start the SQL server. Windows could not start the SQL Server (MSSQLSERVER) on Local Computer. Error 1069: The service did not start due to a logon failure

Adventureworks database installation in sql server 2014

Adventureworks database is sample database sql server. Until 2012, Microsoft provided sample databases are in the format of mdf and ldf file downloads, we have to download and attach the mdf and ldf file to install Adventure works 2008/2008 R2/2012. This has changed completely in 2014. Download Adventureworks database from codeplex site. Adventureworks database installation […]

How to change the database owner in SQL Server

Who creates the database is the owner of the database. We can change the owner of the database using either sp_changedbowner or ALTER AUTHORIZATION. When we create a database, a row created in sys.databases.It stores information like database owner, creation date, size.. We can find out the database owner name either by using T-SQL query […]

SQL Server Shortcuts

Following are most useful SQL Server Shortcuts. Shortcut Description SSMS To Open SQL Server Management Studio Ctrl+N To open new query window in current connection Ctrl+Shift+N Open Project Ctrl+O Open File Ctrl+Shift+O Open Project Ctrl+S To save the currently query window with sql extension Ctrl+R To show/Hide the results Pane

Restore master database in SQL Server

If master database is damaged or unusable, then we have to restore the master database. We can restore the database in two scenarios. 1. If server is accessible: step1: Put the server in single user mode add -m to the startup parameters in the sql server service using the configuration manager and restart the server […]

Start SQL Server in single user mode

Single User mode in SQL Server can connect with single user only and did not start checkpoint process. We have to start SQL Server in single user mode, when issues are like master Database restore, Sysadmin locked out etc,.. Process is very simple. This is three step process. 1) Open SQL Server COnfiguration Manager by […]

Powered by k2schools