<< < 42 43 44 45 46 47 48 49 50 51 52 > >>   ∑:1233  Sort:Rank

Using Subqueries with the IN Operators in SQL Server
How To Use Subqueries with the IN Operators in SQL Server? A subquery can be used with the IN operator as "expression IN (subquery)". The subquery should return a single column with one or more rows to form a list of values to be used by the IN operation. The following tutorial exercise shows you ho...
2016-10-29, 1252🔥, 0💬

"AS" - Naming Query Output Columns in SQL Server
How To Name Query Output Columns in SQL Server? Each column in the query output has a default name. If you don't like the default name, you can specify a new name for any column in the query output by using the AS clause. The following statement shows you a good example: SELECT tag AS Category, YEAR...
2016-10-29, 1231🔥, 0💬

What Is a Subquery in a SELECT Query Statement in SQL Server
What Is a Subquery in a SELECT Query Statement in SQL Server? A subquery is a SELECT statement used as part of the selection criteria of the main SELECT statement. The subquery specified in the WHERE clause will be evaluated repeated on each row of the selection base table. The output of the subquer...
2016-10-29, 1139🔥, 0💬

Counting Rows with the COUNT(*) Function in SQL Server
How To Count Rows with the COUNT(*) Function in SQL Server? If you want to count the number of rows, you can use the COUNT(*) function in the SELECT clause. The following tutorial exercise shows you some good examples: SELECT COUNT(*) FROM fyi_links GO 7 SELECT COUNT(*) FROM fyi_links WHERE url LIKE...
2016-10-26, 3277🔥, 0💬

Selecting All Columns of All Rows from a Table in SQL Server
How To Select All Columns of All Rows from a Table with a SELECT statement in SQL Server? The simplest query statement is the one that selects all columns of all rows from a single table: "SELECT * FROM tableName". The (*) in the SELECT clause tells the query to return all columns. The missing WHERE...
2016-10-26, 3229🔥, 0💬

Selecting Some Specific Columns from a Table in SQL Server
How To Select Some Specific Columns from a Table in a Query in SQL Server? If you want explicitly tell the query to return some specific columns, you can specify the column names in the SELECT clause. The following select statement returns only three columns, "id", "created" and "url" from the table...
2016-10-26, 1984🔥, 0💬

Using SELECT Statements on Views in SQL Server
Can SELECT Statements Be Used on Views in SQL Server? Select (query) statements can be used on views in the same way as tables. The following tutorial exercise helps you creating a view and running a query statement on the view: CREATE VIEW myLinks AS SELECT * FROM fyi_links WHERE url LIKE '%fyi%' G...
2016-10-26, 1847🔥, 0💬

Selecting Some Specific Rows from a Table in SQL Server
How To Select Some Specific Rows from a Table in SQL Server? If you don't want select all rows from a table, you can specify a WHERE clause to tell the query to return only the rows that meets the condition defined in the WHERE clause. The WHERE clause condition is a normal Boolean expression. If an...
2016-10-26, 1587🔥, 0💬

Using SELECT Statements and GROUP BY Clauses in SQL Server
Where to find answers to frequently asked questions on Using SELECT Statements and GROUP BY Clauses in SQL Server? Here is a list of frequently asked questions and their answers compiled by FYIcenter.com DBA team on Using SELECT Statements and GROUP BY Clauses in SQL Server. Clear answers are provid...
2016-10-26, 1498🔥, 0💬

Sorting Query Output in Descending Order in SQL Server
How To Sort Query Output in Descending Order in SQL Server? If you want to sort a column in descending order, you can specify the DESC keyword in the ORDER BY clause. The following SELECT statement first sorts the "tag" in descending order, then sorts the "counts" in ascending order: SELECT tag, cou...
2016-10-26, 1420🔥, 0💬

What Is a SELECT Query Statement in SQL Server
What Is a SELECT Query Statement in SQL Server? The SELECT statement is also called the query statement. It is the most frequently used SQL statement in any database application. SELECT statements allows you to retrieve data from one or more tables or views, with different selection criteria, groupi...
2016-10-26, 1382🔥, 0💬

Using ORDER BY with UNION Operators in SQL Server
How To Use ORDER BY with UNION Operators in SQL Server? If you need to sort the output from two queries grouped together with a UNION operator, you need to apply the ORDER BY clause at the group level, not at the subquery level. Note that SQL Server and MySQL react differently to the ORDER BY clause...
2016-10-26, 1380🔥, 0💬

Sorting Query Output by Multiple Columns in SQL Server
Can the Query Output Be Sorted by Multiple Columns in SQL Server? You can specifying multiple columns in the ORDER BY clause as shown in the following example statement, which returns rows sorted by "tag" and "counts" values: SELECT tag, counts, url, created FROM fyi_links ORDER BY tag, counts GO ta...
2016-10-26, 1369🔥, 0💬

Testing Table for SELECT Statements in SQL Server
How To Create a Testing Table with Test Data to try with SELECT statements in SQL Server? If you want to follow the tutorial exercises presented in this collection, you need to create a testing table and insert some test data, as shown in the following sample script: CREATE TABLE fyi_links (id INTEG...
2016-10-26, 1365🔥, 0💬

Sorting Query Output with ORDER BY Clauses in SQL Server
How To Sort the Query Output with ORDER BY Clauses in SQL Server? If you want the returning rows to be sorted, you can specify a sorting expression in the ORDER BY clause. The simplest sort expression is column name who's values will be sorted by. The following select statement returns rows sorted b...
2016-10-26, 1350🔥, 0💬

UNION - Merging Outputs from Two Queries Together in SQL Server
How To Use UNION to Merge Outputs from Two Queries Together in SQL Server? If you have two queries that returns the same row fields, you can merge their outputs together with the UNION operator. The following tutorial exercise shows you how to use the UNION operator: SELECT * FROM fyi_links WHERE ta...
2016-10-26, 1345🔥, 0💬

Filtering Out Duplications in the Returning Rows in SQL Server
How To Filter Out Duplications in the Returning Rows in SQL Server? If there are duplications in the returning rows, and you want to remove the duplications, you can use the keyword DISTINCT in the SELECT clause. The DISTINCT applies to the combination of all data fields specified in the SELECT clau...
2016-10-26, 1291🔥, 0💬

Adding More Test Data for Query Statements in SQL Server
How To Add More Data to the Testing Table in SQL Server? If you want to continue with other tutorial exercises in this FAQ collection, you need to add more data to the testing table. Follow the script below to add a new column and more rows: ALTER TABLE fyi_links ADD tag VARCHAR(8) GO UPDATE fyi_lin...
2016-10-26, 1259🔥, 0💬

"GROUP BY" - Dividing Query Output into Multiple Groups in SQL Server
How To Divide Query Output into Multiple Groups with the GROUP BY Clause in SQL Server? Sometimes, you want to divide the query output into multiple groups, and apply group functions on each individual groups. Dividing query output into multiple groups can be done with the GROUP BY clause. Here is t...
2016-10-25, 2933🔥, 0💬

How To Count Duplicated Values in a Column? in SQL Server
How To Count Duplicated Values in a Column in SQL Server? If you have a column with duplicated values, and you want to know what are those duplicated values are and how many duplicates are there for each of those values, you can use the "GROUP BY ... HAVING" clause as shown in the following example....
2016-10-25, 2489🔥, 0💬

sys.triggers - Listing All Triggers in the Database in SQL Server
How To List All Triggers in the Database with sys.triggers in SQL Server? If you want to list all triggers defined in the current database, you can use the catalog view, sys.triggers, as shown in the following tutorial example: USE FyiCenterData; GO CREATE TRIGGER new_user ON fyi_users AFTER INSERT ...
2016-10-25, 1843🔥, 0💬

Mixing Group Functions with Non-group Selection Fields in SQL Server
Can Group Functions Be Mixed with Non-group Selection Fields in SQL Server? If a group function is used in the SELECT clause, all other selection fields must be group level fields. Non-group fields can not be mixed with group fields in the SELECT clause. The script below gives you an example of inva...
2016-10-25, 1562🔥, 0💬

Creating and Managing Triggers in SQL Server
Where to find answers to frequently asked questions on Creating and Managing Triggers in SQL Server? Here is a list of frequently asked questions and their answers compiled by FYIcenter.com DBA team on Creating and Managing Triggers in SQL Server. Clear explanations and tutorial exercises are provid...
2016-10-25, 1441🔥, 0💬

Testing DML Triggers in SQL Server
How To Test a DML Trigger in SQL Server? To test a DML trigger defined on a table, you just need to execute several INSERT, UPDATE and DELETE statements on that table as shown in this tutorial example: USE FyiCenterData; GO INSERT INTO fyi_users (name) VALUES ('FYI Admin'); GO Records are inserted, ...
2016-10-25, 1365🔥, 0💬

<< < 42 43 44 45 46 47 48 49 50 51 52 > >>   ∑:1233  Sort:Rank