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

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, 1357🔥, 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, 1330🔥, 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, 1306🔥, 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, 1298🔥, 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, 1294🔥, 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, 1285🔥, 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, 1262🔥, 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, 1244🔥, 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, 1238🔥, 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, 2193🔥, 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, 2076🔥, 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, 1978🔥, 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, 1763🔥, 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, 1631🔥, 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, 1377🔥, 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, 1350🔥, 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, 1283🔥, 0💬

"DROP TRIGGER" - Deleting Existing Triggers in SQL Server
How To Delete Existing Triggers using "DROP TRIGGER" in SQL Server? If you don't want to use a trigger any more, you should delete it from the database by using the "DROP TRIGGER" statement as shown in tutorial example: USE FyiCenterData; GO DROP TRIGGER new_user; GO SELECT * FROM sys.triggers GO na...
2016-10-24, 1221🔥, 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, 1217🔥, 0💬

Rolling Back the DDL Statement in a Trigger in SQL Server
Can You Roll Back the DDL Statement in a Trigger in SQL Server? Can you roll back the DDL statement in a trigger? The answer is yes. Since the DDL statement that fires the trigger and the statements defined inside the trigger are all executed as a single statement batch, you can add a ROLLBACK state...
2016-10-22, 2567🔥, 0💬

sys.schemas - Listing All Schemas in a Database in SQL Server
How To List All Schemas in a Database in SQL Server? If you want see all existing schemas in the current database, you can use view sys.schemas as shown in the example below: USE FyiCenterData; GO SELECT * FROM sys.schemas; GO name schema_id principal_id -------------------- ----------- ------------...
2016-10-22, 2218🔥, 0💬

"sys.objects" - Listing All Objects in a Given Schema in SQL Server
How To List All Objects in a Given Schema in SQL Server? If you are wonder what objects are stored in a given schema as an object container, you can use view "sys.objects" to get a list of all objects in a schema. The tutorial exercise shows you how to list all objects in schema "fyi" and "dbo": -- ...
2016-10-22, 2015🔥, 0💬

Creating a Logon Trigger in Express Edition in SQL Server
Can You Create a Logon Trigger in SQL Server 2005 Express Edition in SQL Server? Can you create a logon trigger in SQL Server 2005 Express Edition? The answer is no. LOGON is not a supported event type in Express Edition. The script below shows you the error message when you try to create a logon tr...
2016-10-22, 1715🔥, 0💬

"ALTER AUTHORIZATION" - Changing the Ownership of a Schema in SQL Server
How To Change the Ownership of a Schema in SQL Server? If you want to change the owner of a schema, you can use the "ALTER AUTHORIZATION" statement using the following syntax: ALTER AUTHORIZATION ON SCHEMA::schema_name TO user_name The following tutorial example shows you how to change ownership of ...
2016-10-22, 1574🔥, 0💬

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