Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

MSSQL%20Interview%20Questions%20and%20Answers

Question: How to read data in a table with "SELECT" statements?
Answer: Now this part is for creating database objects with Transact-SQL statements. This Question shows you how to create a database, create a table in the database, and then access and change the data in the table. Because this Answer is an introduction to using Transact-SQL, it does not use or describe the many options that are available for these statements. This Guide assumes that you are running SQL Server Management Studio Express.

Use the SELECT statement to read the data in a table. The SELECT statement is one of the most important Transact-SQL statements, and there are many variations in the syntax. For this Answer, you will work with five simple versions.

To read the data in a table - Type and execute the following statements to read the data in the Products table.

-- The basic syntax for reading data from a single table
SELECT ProductID, ProductName, Price, ProductDescription FROM dbo.Products
GO

You can use an asterisk to select all the columns in the table. This is often used in ad hoc queries. You should provide the column list in you permanent code so that the statement will return the predicted columns, even if a new column is added to the table later.

-- Returns all columns in the table
-- Does not use the optional schema, dbo
SELECT * FROM Products
GO
Is it helpful? Yes No

Most helpful rated by users:

©2024 WithoutBook