SQL Server Management Studio provides rich commands for database connection, database manipulation, and database object operations such as create, insert, update, and delete.
With the help of the Management Studio, QA testers do not need to memorize various commands. However, memorizing basic commands and their syntax are extremely important for test work efficiency.
To CREATE, DROP,SELECT, INSERT, UPDATE, and DELETE, you can right click on the database objects like tables or views, and select the commands you want to execute.
To select top 1000 rows from the HumanResources.Department table, you right click mouse on the table and click on "Select Top 1000 Rows" option as shown on the picture below.
This will display top 1000 rows from the table as shown below.
The SQLQuery syntax window display Select statement corresponding to the "Select Top 1000 Rows" operation. If you would like to select different numbers or apply some conditional statement, you can use SQL Query window.
/****** Script for SelectTopNRows command from SSMS ******/ SELECT TOP 1000 [DepartmentID] ,[Name] ,[GroupName] ,[ModifiedDate] FROM [AdventureWorks2008].[HumanResources].[Department]
To select top 10
/****** Script for SelectTopNRows command from SSMS ******/ SELECT TOP 10 [DepartmentID] ,[Name] ,[GroupName] ,[ModifiedDate] FROM [AdventureWorks2008].[HumanResources].[Department]
Common Used Commands:
- CREATE To: used for creating a new table with the same table design
- DROP To: used for dropping the table
- DROP and CREATE To: used for dropping existing table and creating a new table with the same table design
- SELECT To: used for retrieving data in the table
- INSERT To: used for inserting data into the table
- UPDATE To: used for updating records in the table
- DELETE To: used for deleting records in the table.