<< < 13 14 15 16 17 18 19 20 > >>   ∑:474  Sort:Rank

"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, 3009🔥, 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, 2533🔥, 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, 1884🔥, 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, 1614🔥, 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, 1471🔥, 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, 1391🔥, 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, 1389🔥, 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, 1360🔥, 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, 1329🔥, 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, 1325🔥, 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, 1323🔥, 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, 1318🔥, 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, 1287🔥, 0💬

HAVING - Apply Filtering Criteria at Group Level in SQL Server
How To Apply Filtering Criteria at Group Level with The HAVING Clause in SQL Server? Let's say you have divided the query output into multiple groups with the GROUP BY clause. Now you are only interested in some of the groups, not all the groups. If you want to filter out some groups from the query,...
2016-10-25, 1277🔥, 0💬

Basic Features of a Trigger in SQL Server
What Are the Basic Features of a Trigger in SQL Server? Since a SQL Server trigger is a really an event handler, it has the following basic features similar to event handlers in other programming languages: Event Type - It must be declared to handle a specific event, like a DELETE event. Object Scop...
2016-10-25, 1263🔥, 0💬

sys.trigger_events - Event List of an Existing Trigger in SQL Server
How To See the Event List of an Existing Trigger using sys.trigger_events in SQL Server? If what are the DML events an existing trigger is handling, you can use the catalog view, sys.trigger_events. You need to join sys.trigger_events and sys.triggers to get a better list as shown in this tutorial e...
2016-10-24, 2232🔥, 0💬

sys.sql_modules - Getting Trigger Definitions Back in SQL Server
How To Get the Definition of a Trigger Back in SQL Server? If you want get the definition of an existing trigger back from the SQL Server, you can use the catalog view called sys.sql_modules, which stores definitions of views, stored procedures, and triggers. The sys.sql_modules holds trigger defini...
2016-10-24, 2119🔥, 0💬

"DISABLE TRIGGER" - Disabling Triggers in SQL Server
How To Disable Triggers using "DISABLE TRIGGER" in SQL Server? If want to stop the execution of an existing trigger temporarily, you can use the "DISABLE TRIGGER" statement to disable it. The disabled trigger will be kept in the database. If you want to resume the execution of a disabled trigger, yo...
2016-10-24, 2030🔥, 0💬

Improving the Trigger to Handle NULL Values in SQL Server
How To Improve the Trigger to Handle NULL Values in SQL Server? When a NULL value is concatenated with a string, the result will be a null value. So if you want the trigger to properly report NULL values, you need to enhance the trigger as shown in the following tutorial example: USE FyiCenterData; ...
2016-10-24, 1805🔥, 0💬

Creating Triggers for INSERT Statements Only in SQL Server
How To Create a Trigger for INSERT Only in SQL Server? The trigger, dml_message, provided in previous tutorials was defined to handle all 3 types of DML statements, INSERT, UPDATE, and DELETE. If you do not want the trigger to handle all 3 types of DML statements, you can list only 1 or 2 of the sta...
2016-10-24, 1674🔥, 0💬

Triggers with Multiple Affected Rows in SQL Server
What Happens to a Trigger with Multiple Affected Rows in SQL Server? If there is only one row affected by a DML statement, we know that the DML trigger will be executed once. But how many times the DML trigger will be executed if the DML statement resulted multiple affected rows? The answer is still...
2016-10-24, 1417🔥, 0💬

"INSERTED" - New Record of an DML Event Instance in SQL Server
How To Access the Inserted Record of an Event in SQL Server? When a DML event occurs, SQL Server will prepare a temporary table called "INSERTED", which contains the new record of the affected row, which is: A copy of the inserted row for an INSERT statement. A copy of the updated row for an UPDATE ...
2016-10-24, 1388🔥, 0💬

"DELETED" - Old Record of an DML Event Instance in SQL Server
How To Access the Deleted Record of an Event in SQL Server? When a DML event occurs, SQL Server will prepare a temporary table called "DELETED", which contains the old record of the affected row, which is: A copy of the deleted row for a DELETE statement. A copy of the row to be updated for an UPDAT...
2016-10-24, 1320🔥, 0💬

"ALTER TRIGGER" - Modifying Existing Triggers in SQL Server
How To Modify Existing Triggers using "ALTER TRIGGER" in SQL Server? If you want to make changes to an existing trigger, you could use the "ALTER TRIGGER" statements to refine the trigger again. The tutorial exercise below shows you how to modify the trigger defined in a previous tutorial: USE FyiCe...
2016-10-24, 1252🔥, 0💬

<< < 13 14 15 16 17 18 19 20 > >>   ∑:474  Sort:Rank