<< < 14 15 16 17 18 19 20 21 22 > >>   ∑:509  Sort:Rank

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, 1788🔥, 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, 1629🔥, 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, 1621🔥, 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, 1586🔥, 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, 1558🔥, 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, 1536🔥, 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, 1503🔥, 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, 1499🔥, 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, 1494🔥, 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, 1435🔥, 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, 1387🔥, 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, 3222🔥, 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, 2649🔥, 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, 1987🔥, 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, 1730🔥, 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, 1595🔥, 0💬

Using Multiple Columns in the GROUP BY Clause in SQL Server
Can Multiple Columns Be Used in GROUP BY in SQL Server? If you want to break your output into smaller groups, you can specify multiple column names or expressions in the GROUP BY clause. Output in each group must satisfy a specific combination of the expressions listed in the GROUP BY clause. The mo...
2016-10-25, 1503🔥, 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, 1487🔥, 0💬

Group Functions in Query Statements in SQL Server
What Are Group Functions in Query Statements in SQL Server? Group functions are functions applied to a group of rows. Examples of group functions are: COUNT(*) - Returns the number of rows in the group. MIN(exp) - Returns the minimum value of the expression evaluated on each row of the group. MAX(ex...
2016-10-25, 1477🔥, 0💬

Using Group Functions in the ORDER BY Clause in SQL Server
Can Group Functions Be Used in the ORDER BY Clause in SQL Server? If the query output is aggregated as groups, you can sort the groups by using group functions in the ORDER BY clause. The following statement returns the maximum "counts" in each group, determined by a unique combination of tag and ye...
2016-10-25, 1466🔥, 0💬

"CREATE TRIGGER" - Creating a DML Trigger in SQL Server
How To Create a DML Trigger using CREATE TRIGGER Statements in SQL Server? A DML trigger is a trigger declared to handle a DML event, which occurs when an INSERT, UPDATE or DELETE statement is executed. If you want to create a DML trigger, you should use the "CREATE TRIGGER" statement in the followi...
2016-10-25, 1446🔥, 0💬

Creating a Simple Table to Test Triggers in SQL Server
How To Create a Simple Table to Test Triggers in SQL Server? If you want to follow other tutorial examples included in this collection, you need to run this SQL script to create a simple table called fyi_users: USE FyiCenterData; GO DROP TABLE fyi_users; GO CREATE TABLE fyi_users ( id INTEGER IDENTI...
2016-10-25, 1442🔥, 0💬

What Are Triggers in SQL Server
What Are Triggers in SQL Server? A trigger is a special kind of stored procedure that automatically executes when an event occurs in the database server. A trigger is really an event handler. SQL Server allows users to create triggers (event handlers) for 3 types of events: DML Event - Occurs when a...
2016-10-25, 1439🔥, 0💬

Using Group Functions in the SELECT Clause in SQL Server
How To Use Group Functions in the SELECT Clause in SQL Server? If group functions are used in the SELECT clause, all rows that meet the criteria defined in the WHERE clause will be treated as a single group. The group functions will be apply all rows in that group as a whole. The final output of the...
2016-10-25, 1398🔥, 0💬

<< < 14 15 16 17 18 19 20 21 22 > >>   ∑:509  Sort:Rank