Skip to main content

Posts

Showing posts with the label SQL SERVER

SQL Server 2014 Keyboard Shortcut Keys in Management Studio

Open New Query Window (Ctrl + N) Shortcut key to open new query window in  sql server  management studio is  Ctrl + N . It will open new key query window in current connection. Execute Highlighted Query (Ctrl + E) If want to execute highlighted or selected query in  sql server  management studio shortcut key is  Ctrl + E . Toggle between Open Tabs (Ctrl + Tab) If we want to toggle or switch between opened tabs in  sql server  management studio shortcut key is Ctrl + Tab . It will help us to move between opened tabs easily. Show / Hide Result Pane (Ctrl + R) By using Ctrl + R shortcut key we can show / hide result pane of executed query. We can easily make full screen by hiding / closing result pane using shortcut key  Ctrl + R . Display Estimated Execution Plan (Ctrl + L) If we want to show execution plan for queries which we are executing shortcut key is  Ctrl + L .   If we use Ctrl + L key com...

Main differences between Stored procedures and Functions in Sql Server ?

Stored Procedure: A stored procedure is a pre-compiled group of Transact-SQL statements .We can say a stored procedure is a prepared SQL code that we save so that we can reuse the code over and over again. If a repetitive T-SQL task has to be executed within an application, then the best way for it is to create stored procedure. It is always recommended to create Stored Procedure instead of writing Inline queries so that we can just call the Stored Procedures whenever required instead of writing Inline queries again and again each time. You can also pass parameters to the stored procedure, so depending on what the need is the stored procedure can act accordingly based on the parameter values that were passed to it. Function: Function in Sql Server is a Transact-SQL or common language runtime (CLR) routine that takes parameters, performs an action, and returns the result of that action as a value. The return value can either be a scalar (single) value or a table. Difference be...

Difference between Delete and Truncate in sql server ?

DELETE The DELETE command is used to remove rows from a table. A WHERE clause can be used to delete specified records based on conditions. If no WHERE condition is specified, all rows will be removed. After performing a DELETE operation you need to COMMIT or ROLLBACK the transaction to make the change permanent or to undo it. It removes rows from a table or view. DELETE statements delete rows one at a time, logging each row in the transaction log, as well as maintaining log sequence number (LSN) information. e.g. delete from employee ;( this command will remove all the data from employee table) delete from employee where emp_id=100;(This command will remove only that row from employee table where emp_id=100); TRUNCATE TRUNCATE removes all rows from a table without logging the individual row deletions .No triggers will be fired in TRUNCATE. As such, TRUNCATE is faster and doesn’t use as much undo space as a DELETE. e.g. truncate table employee.( This command will remove all the da...

What is Stored Procedure?

A stored procedure is a pre-compiled group of Transact-SQL statements .We can say a stored procedure is a prepared SQL code that we save so that we can reuse the code over and over again. If a repetitive T-SQL task has to be executed within an application, then the best way for it is to create stored procedure. It is always recommended to create Stored Procedure instead of writing Inline queries so that we can just call the Stored Procedures whenever required instead of writing Inline queries again and again each time. You can also pass parameters to the stored procedure, so depending on what the need is the stored procedure can act accordingly based on the parameter values that were passed to it. Implementation: Let's create the table and the basic stored procedure to perform Save, Update, Delete, Bind and Search operation on Sql server database table. First of all create a database in Sql server and name it "BooksDb" or whatever you want. Column Name datatyp...

How to start Sql server 2008 / 2012 from command prompt?

SQL Server 2008/2012 To start SQL Server Management Studio 2008 or SQL Server Management Studio 2012 from Command Prompt: Click Start -> Run -> Type SSMS.exe and press enter or Start -> Run -> cmd -> Type SSMS.exe and press enter You can also pass different parameters with the command. To see the list of parameters suffix the command as: Click Start -> Run -> Type ssms.exe /? Or ssms.exe -? or Start -> Run -> cmd -> Type SSMS.exe /? Or ssms.exe -? Usage: ssms.exe [-S server_name[\instance_name]] [-d database] [-U user] [-P password] [-E] [file_name[, file_name]] [/?] [-S The name of the SQL Server instance to which to connect] [-d The name of the SQL Server database to which to connect] [-E] Use Windows Authentication to login to SQL Server [-U The name of the SQL Server login with which to connect] [-P The password associated with the login] [file_name[, file_name]] names of files to load [-nosplash] Supress splash screen [/?] Displays this usage i...