Loop
Loop
A Stored Procedure is nothing but a frequently used SQL query. Queries such as a
SELECT query, which would often be used to retrieve a set of information many times
within a database, can be saved as a Stored Procedure. The Stored Procedure, when
called, executes the SQL query save within the Stored Procedure.
You can execute the Stored Proc by using the command Exec Procedure_Name;
32. What is a trigger in SQL Server?
Triggers in SQL Server are automatic functions that get executed AFTER or BEFORE an
event occurs.
For example: Trigger to update the employee’s salary to $40000 AFTER getting a
promotion to job level band D1. It is also referred to as a type of Stored
Procedure. The type of trigger as AFTER or BEFORE is defined in the syntax of the
trigger itself.
33. How to open SQL Server
Launch the SQL Server Management Studio from the START menu. Login using Windows
Authentication. In the Object Explorer window pane, you can view the list of
databases and corresponding objects.
34. How to connect SQL Server
The most common way of connecting to a SQL Server is using Windows Authentication.
Make sure to select the Server Name as the desktop or laptop system name.
35. What is replication in SQL Server?
Replication of a database node is the most common way to prevent the complete loss
of any data. When a database is replicated/ taken a copy of, it can be used across
databases for data reuse and synchronization. Apart from the primary motive of data
backup, replicated data is also used for data analysis in Big Data projects.
36. How to open SQL Server configuration manager
Click on the START menu and select All Programs. Select Microsoft SQL Server,
select Configuration Tools, and then select SQL Server Configuration tools. In
that, select the SQL Server Configuration Manager.
37. What is a collation in SQL Server?
Collation refers to a set of pre-defined rules on SQL Server, which define the
encoding rules of character data both at a database and server level. Collation
rules can be used on Metadata as well.
38. How to use SQL Server
SQL Server is used to retrieve and process various data that is built on a
relational model.
Some of the common actions that can be taken on the data are CREATE, DELETE,
INSERT, UPDATE, SELECT, REVOKE, etc.
SQL Server can also be used to import and export data from different data sources.
SQL Server can also be connected to various other databases/ .Net framework using
Connection Strings.
SQL Server can also be used in conjunction with Big Data tools like Hadoop.
39. What is a function in SQL Server?
Functions are pre-written codes that return a value and which help the user achieve
a particular task concerning viewing, manipulating, and processing data.
AGGREGATE FUNCTIONS:
COUNT()
STRING FUNCTIONS:
COALESCE()
CAST()
CONCAT()
SUBSTRING()
DATE FUNCTIONS:
GETDATE()
DATEADD()
DATEDIFF()
There are many types of functions such as Aggregate Functions, Date Functions,
String Functions, Mathematical functions, etc.
40. How to find nth highest salary in SQL Server without using a subquery
This is one of the common SQL Interview questions that have been asked in several
Job interviews.
Query to find the 10 highest salary. For up-gradation of the b10 band.
with result as
In this way, by replacing the salaryrank value, we can find the nth highest salary
in any organisation.
41. How to install SQL Server in Windows 10
Temporary tables can be used to retain the structure and a subset of data from the
original table from which they were derived.
Syntax:
1
2
3
Temporary tables do not occupy any physical memory and can be used to retrieve data
faster.
43. What is schema in SQL Server?
This is one of the common SQL Interview questions that have been asked in several
Job interviews.
There are different types of schema. Some of the most popular ones are the Star
schema and Snowflake schema. Star schema is the one that has the entities
represented in a star shape, and the snowflake schema has its entities represented
in a snowflake shape.
PostgreSQL is one of the most widely and popularly used languages for Object-
Relational Database Management systems. It is mainly used for large web
applications. It is an open-source, object-oriented, -relational database system.
It is extremely powerful and enables users to extend any system without problem. It
extends and uses the SQL language in combination with various features for safely
scaling and storage of intricate data workloads.
2. List different datatypes of PostgreSQL?
UUID
Numeric types
Boolean
Character types
Temporal types
Geometric primitives
Arbitrary precision numeric
XML
Arrays etc
Indices in PostgreSQL allow the database server to find and retrieve specific rows
in a given structure. Examples are B-tree, hash, GiST, SP-GiST, GIN and BRIN.
Users can also define their indices in PostgreSQL. However, indices add overhead to
the data manipulation operations and are seldom used
4. What are tokens in PostgreSQL?
Tokens in PostgreSQL act as the building blocks of a source code. They are composed
of various special character symbols. Commands are composed of a series of tokens
and terminated by a semicolon(“;”). These can be a constant, quoted identifier,
other identifiers, keyword or a constant. Tokens are usually separated by
whitespaces.
5. How to create a database in PostgreSQL?
We can create the database by using the syntax:- CREATE DATABASE <dbname>;
We can create the database by using the syntax:- createdb [option…] <dbname>
[description]
Various options can be taken by the createDB command based on the use case.
6. How to create a table in PostgreSQL?
You can create a new table by specifying the table name, along with all column
names and their types:
CREATE TABLE [IF NOT EXISTS] table_name (