Select Records from Table via SQL using SELECT:
(1) Before starting SQL query, understand the advantages of language.
- SQL stands for Structured Query Language.
- SQL can retrieve data from a database.
- SQL can insert, update, delete records in a database.
- SQL can create new databases.
- SQL can create new tables, procedure & views.
(2) “SELECT” statement used for select records in the table from database.
(3) Syntax of “SELECT” statement is-
SELECT column1, column2, … FROM table_name; |
(4) Let’s take an example to select records for “Vendor table”.
(5) Select the database in SQL server and click on the “New Query” button as shown.
(6) After that new query editor open as shown.
(7) After doing the above steps, write a query in the editor, in which select all records of Vendor table, as shown.
Source Code:
–// For selecting all fields in table Select * from dbo.[CRONUS India Ltd_$Vendor$437dbf0e-84ff-417a-965d-ed2bb9650972] –// For selecting all fields in table –// For selecting particular fields in table Select [No_], [Name], [Address] from dbo.[CRONUS India Ltd_$Vendor$437dbf0e-84ff- 417a-965d-ed2bb9650972] –// For selecting particular fields in table |
(8) After writing the query, then execute the query (Shortcut keys is F5) as shown.
(9) After executing the two queries in the same editor, SQL gives two results. Recommended write and execute queries one by one for reporting.