Full Trust European Hosting

BLOG about Full Trust Hosting and Its Technology - Dedicated to European Windows Hosting Customer

SQL Server 2019 Hosting Europe - HostForLIFE.eu :: Create and Schedule a Job in SQL Server

clock August 16, 2019 09:27 by author Peter

In this article, you will learn how to create a new job and schedule that job for execution in SQL Server. What is a SQL Job? A job is a specified series of actions that SQL Server Agent performs. Use jobs to define an administrative task that can be run one or more times and monitored for success or failure. A job can run on one local server or on multiple remote servers. Some examples of SQL Jobs are automatic weekly backup, sending auto emails, newsletters, writing log files, and audit logs.


First of all, start SQL Server 2008 Management Studio. Expand Databases node and select a database you want to use to create and schedule a job from.

Image 1.
For this database I am going to create a job and schedule that job.

Now click on SQL Server agent and select "Jobs" and right-click and click on "New Job".

Image 2.

As you can see there are many steps, so let's go one by one. First provide a job name and description and click "OK".
General Tab


Image 3.

Now click on "Next". The step name is Steps and provides a name, type and select database and write a command to save in a location and click "OK".
Steps Tab

Image 4.

Now click on the "Schedules" tab and provide name, type, frequency and click "OK".
Schedules Tab

Image 5.

Now click on the alerts tab and click on the "Add" button and provide alert name, type, database name and click "Ok".
Alerts Tab

Image 6.

Now click on the notifications tab and select how you want notifications.
Notifications Tab

Image 7.

The final tab is the "Targets" tab that shows you the options of the target server, you can also select multiple target servers.
Targets Tab

Image 8.
Summary
In this article, we learned how to setup and schedule a job in SQL Server.

HostForLIFE.eu SQL Server 2019 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.

 



SQL Server 2019 Hosting Europe - HostForLIFE.eu :: Introduction To SQL And SQL Commands

clock July 31, 2019 12:27 by author Peter

SQL

SQL stands for Structured Query Language. SQL is used to create, remove, alter the database and database objects in a database management system and to store, retrieve, update the data in a database. SQL is a standard language for creating, accessing, manipulating database management system. SQL works for all modern relational database management systems, like SQL Server, Oracle, MySQL, etc.

Different types of SQL commands
SQL commands can be categorized into five categories based on their functionality.

DDL
DDL stands for data definition language. DDL commands are used for creating and altering the database and database object in the relational database management system, like CREATE DATABASE, CREATE TABLE, ALTER TABLE, etc. The most used DDL commands are CREATE, DROP, ALTER, and TRUNCATE.
    CREATE
    CREATE command is used to create a database and database object like a table, index, view, trigger, stored procedure, etc.

    Syntax
    CREATE TABLE Employee (Id INT, Name VARHCAR (50), Address VARCHAR (100));

    ALTER
    ALTER command is used to restructure the database object and the settings in the database.

    Syntax
    ALTER TABLE Employee ADD Salary INT;

    TRUNCATE
    TRUNCATE command is used to remove all the data from the table. TRUNCATE command empties a table.

    Syntax
    TRUNCATE TABLE Employee;

    DROP
    DROP command is used to remove the database and database object.

    Syntax
    DROP TABLE Employee;

DML
DML stands for data manipulation language. DML commands are used for manipulating data in a relational database management system. DML commands are used for adding, removing, updating data in the database system, like INSERT INTO TableName, DELETE FROM TableName, UPDATE tableName set data, etc. The most used DML commands are INSERT INTO, DELETE FROM, UPDATE.
    INSERT INTO
    INSERT INTO command is used to add data in the database table.

    Syntax
    INSERT INTO Employee (Id, Name, Address, Salary) VALUES (1, ‘Arvind Singh’, ‘Pune’, 1000);

    UPDATE
    UPDATE command is used to update data in the database table. A condition can be added using the WHERE clause to update a specific row.

    Syntax
    UPDATE Employee SET Address = ‘Pune India’, Salary = 100 WHERE Id =1;

    DELETE
    DELETE command is used to remove data from the database table. A condition can be added using the WHERE clause to remove a specific row which meets the condition.

    Syntax
    DELETE FROM Employee WHERE Id =1;

DQL
DQL stands for data query language. DQL command is used for fetching the data. DQL command is used for selecting data from the table, view, temp table, table variable etc. There is only one command under DQL which is the SELECT command.

Syntax
SELECT * FROM Employee;

DCL
DCL stands for data control language. DCL commands are used for providing and taking back the access rights on the database and database objects. DCL command used for controlling user’s access on the data. Most used DCL commands are GRANT and REVOKE.

GRANT
GRANT is used to provide access right to user.

Syntax
GRANT INSERT, DELETE ON Employee TO user;

REVOKE
REVOKE command is used to take back access right from the user, it cancels access right of the user from the database object.

Syntax
REVOKE ALL ON Employee FROM user;

TCL
TCL stands for transaction control language. TCL commands are used for handling transactions in the database. Transactions insure data integrity in the multi user environment. TCL commands can rollback and commit data modification in the database. The most used TCL commands are COMMIT, ROLLBACK, SAVEPOINT, and SET TRANSACTION.

COMMIT
COMMIT command is used to save or apply the modification in the database.

ROLLBACK
ROLLBACK command is used to undo the modification.

SAVEPOINT

SAVEPOINT command is used to temporarily save a transaction, the transaction can roll back to this point when it's needed.

Syntax
Just write COMMIT or ROLLBACK or SAVEPOINT;

HostForLIFE.eu SQL Server 2019 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.



SQL Server 2019 Hosting Europe - HostForLIFE.eu :: Triggers In SQL Server

clock July 19, 2019 09:07 by author Peter

A SQL trigger is a database object just like a stored procedure or we can say it is a special kind of Stored Procedure that automatically fires when an event occurs in a database. Learn what is a trigger in SQL Server and how to create triggers on a database table. A SQL trigger is a database object just like a stored procedure, or we can say it is a special kind of stored procedure which fires when an event occurs in a database. We can execute a SQL query that will "do something" in a database when an event is fired.

For example, a trigger can be set on a record insert in a database table. For example, if you want to increase the number of count of blogs in the Reports table when a new record is inserted in the Blogs table, we can create a trigger on the Blogs's table on INSERT and update the Reports table by increaing blog count to 1.

Difference Between a Stored Procedure and a Trigger
Triggers are fired implicitly while stored procedures are fired explicitly.

Types of Triggers
There are two types of triggers:

  • DDL Trigger
  • DML Trigger

DDL Triggers
The DDL triggers are fired in response to DDL (Data Definition Language) command events that start with Create, Alter and Drop, such as Create_table, Create_view, drop_table, Drop_view and Alter_table.

Code of a DDL Trigger
create trigger saftey 
on database 
for 
create_table,alter_table,drop_table 
as 
print'you can not create ,drop and alter table in this database' 
rollback;


When we create, alter or drop any table in a database then the following message appears:

DML Triggers
The DML triggeres are fired in response to DML (Data Manipulation Language) command events that start with with Insert, Update and Delete. Like insert_table, Update_view and Delete_table.
    create trigger deep 
    on emp 
    for 
    insert,update,delete 
    as 
    print'you can not insert,update and delete this table i' 
    rollback;


When we insert, update or delete in a table in a database then the following message appears,
dml-triggers-in-sql.jpg
There are two types of DML triggers

AFTER Triggers
AFTER triggers are executed after the action of an INSERT, UPDATE, or DELETE statement.
    create trigger insertt 
    on emp 
    after insert 
    as 
    begin 
    insert into empstatus values('active') 
    end  


INSTEAD Of Triggers
It will tell the database engine to execute the trigger instead of executing the statement. For example an insert trigger executes when an event occurs instead of the statement that would insert the values in the table .

    CREATE TRIGGER instoftr 
    ON v11 
    INSTEAD OF INSERT 
    AS 
    BEGIN 
    INSERT INTO emp 
    SELECT I.id, I.names 
    FROM INSERTED I 
      
    INSERT INTO emp1values 
    SELECT I.id1, I.name1 
    FROM INSERTED I 
    END  

When we insert data into a view by the following query then it inserts values in both tables :
    insert into v11 values(1,'d','dd') 

You can see both tables by the folowing query:
    select * from emp 
    select * from emp1values 

HostForLIFE.eu SQL Server 2019 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.

 



About HostForLIFE

HostForLIFE is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

We have offered the latest Windows 2019 Hosting, ASP.NET 5 Hosting, ASP.NET MVC 6 Hosting and SQL 2019 Hosting.


Tag cloud

Sign in