> Code Storage

Code Storage

A Technical blog for those who want to gain knowledge about SQL,MySQL,Data Science and real time query

Responsive Ads Here

Advertisement

Wednesday, April 28, 2021

SEVER TYPE IN SSMS ( Sql Server Managment studio)

When you install the SQL Server management studio and then you want to connect with the SQL Server then there are four types of SQL servers are there, and what is the work of that four types of SQL servers. when we have to use that server. let's see what are they:-
  1. Database Engine
  2. Analysis Services
  3. Reporting Services
  4. Integration Services     

  1. Database Engine:- It is a core component of the database engine here core means the main component of the SQL Server management studio. there are have some purposes to use this database engine. the first purpose is to store the data or table which means rows and columns. the second one is processing means after storing the data we have to perform some operations like insert, delete, update. and the third one is security means to provide security to our data.
  2. Analysis Services:- It is an MSBI Tool (business intelligence management tool) and we have to use this tool in the data warehousing for the data storing purpose. Analysis services have to convert the data from 2D( two dimensional ) or tables (rows & columns) to the 3D(three dimensional) formate means graphical formate.
  3. Reporting Services:- It is also called MSBI Tool or SSRS (SQL Server reporting services).reporting services to store the report or document about the company businesses. To use the reporting services can export the data from database engine to the other platform like (MS Word, MS Excel), etc. When you need to export the data from a database to another platform you can use reporting services.
  4. Integration Services:- It is also called MSBI Tool or SSIS (SQL Server integration services). Integration services are used to converting database tables for another database understandable format. This means if you are working in SQL Server database and then you want to convert into another database like the oracle at that time use the integration services.

Tuesday, April 28, 2020

SQL Server Type? Microsoft SQL Server Management Studio

SQL SERVER TYPE IN SSMS

In SQL server,server is a also called services why because every services act like server.there are some type of SQL server.
1.Server type
SSAS, SSRS , SSIS tools we called as a MSBI Tools to intreat with MSBI tool we need a developing tool that developing tool is a BIBS.

2.Business Intelligence tool studio
To interact with database engine we need a developing tools that developing tool is SSMS.
3.SSMS

1.Database Engine:

  • It is core component of SQL server ( core server).The core is nothing but main server.
  • The purpose of using database engine:


  1. Store          : Tables formate (Row & Column)
  2. processing : Perform some operation ( Insert,Update,Delete)
  3. Security     : To data 


 2.Analysis services (SSAS):

  • It is a MSBI tool and this MSBI tool use for data warehousing the purpose of storing the data.
  • Database engine is store the data in two dimensional but they want to convert into three dimensional thats why we use analysis services.
  • When ever we want to convert our 2D formate to 3D formate then we use the analysis services.

3.Reporting services (SSRS):

  • Reporting is nothing but document to store some information and we need to document.
  • To store the business related document then we use the reporting services.
  • When ever we export the data from database that time we need a SSRS tool.

4.Intregration services (SSIS):

  • When ever we need to send information or data from one database to another database at that time we need the intregration services.
  • For this we need MSBI tool then it will converting from database tables in another database understandable formate.



Monday, February 17, 2020

SQL JOIN ? TYPE OF JOIN IN SQL

SQL JOIN:-

SQL join and type of join 

SQL join clause is used to combine rows from the two or more tables or joins in SQL are used to retrieve data from two or more related tables.In general tables are related to each other using foreign key constraint.

In SQL there are different types of joins
  1. Inner join
  2. Outer join 
  3. Cross join

1.Inner join:- 

                       Inner join keywords select the records that have matching in both the table. 

2.Outer join:-

                      Outer join keywords select records that does not have match in both the table.

3.Cross join:-

                      Cross join is join of tables without specifying of join condition the query would return                          all possible combination of the tables in the SQL query.

EXAMPLE:-

  • Order table
1.Order table

  • Customer Table
        

2.Customer table

         Query:-

            SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate
            FROM Orders
            JOIN Customers ON Orders.CustomerID=Customers.CustomerID;

  Output:-


Friday, January 17, 2020

Date and Time format in SQL ?

Date and Time format in SQL

In SQL we have date and time format to show the date and time format in different ways lets see what are the date and time formats are there.

Date,Time,format,SQL
                               
                                                                                1.Date and Time format in SQL


FormateQuerySample
1select convert(varchar,getdate(),1)12/30/08
2select convert(varchar,getdate(),2)08.12.30
3select convert(varchar,getdate(),3)30/12/08
4select convert(varchar,getdate(),4)30.12.08
5select convert(varchar,getdate(),5)30-12-08
6select convert(varchar,getdate(),6)30 Dec 08
7select convert(varchar,getdate(),7)Dec 30 08
10select convert(varchar,getdate(),10)12-30-08
11select convert(varchar,getdate(),11)08/12/30
12select convert(varchar,getdate(),12)08 12 30
23select convert(varchar,getdate(),23)2008-12-30
101select convert(varchar,getdate(),101)12/30/2008
102select convert(varchar,getdate(),102)2008.12.30
103select convert(varchar,getdate(),103)30/12/2008
104select convert(varchar,getdate(),104)30.12.2008
105select convert(varchar,getdate(),105)30-12-2008
106select convert(varchar,getdate(),106)30 Dec 2008
107select convert(varchar,getdate(),107)Dec 30 2008
110select convert(varchar,getdate(),110)12/30/2008
111select convert(varchar,getdate(),111)2008/12/30
112select convert(varchar,getdate(),112)2008 12 30

Time only format:-

In SQL have some time only format lets see what are time format are there :-

Formate Query Sample
8 select convert(varchar,getdate(),8) 00:38:53
14 select convert(varchar,getdate(),14) 00:38:53:840
24 select convert(varchar,getdate(),24) 00:38:53
108 select convert(varchar,getdate(),108) 00:38:53
114 select convert(varchar,getdate(),114) 00:38:53:840


Monday, January 13, 2020

find nth highest salary without using top in sql ?

Find nth highest salary without using top in SQL

highest salary,nth highest salary,top
                                                     1.Find nth highest salary without using top sql
           Here i would use the CTC (common table expression).and i will use a one building function like Dense_Rank() to find the highest salary without using top.

Example:-     with result as 
                      (
                         select salary, dense_rank() over (order by salary desc) as denserank
                 from employee
                     )
                        select salary
                        from result
                        where result.denserank= n ( 1st,2st,3st.........nth)

Here we can get nth highest salary by using this query but end of the query we need to put the nth place which we want like if we want 1 highest salary we need to put 1 and 2  highest salary then put  2 like that we can find nth highest salary in this query.
                                                           But in our table duplicate records are there then above query will not give the perfect result then we should go for the next query. but here we need to use top () function

Example:-  with result as 
                      (
                         select salary, dense_rank() over (order by salary descas denserank
                 from employee
                     )
                        select  top 1 salary
                        from result
                        where result.denserank= n ( 1st,2st,3st.........nth)

Here i have another method to find nth highest salary without using top () function.

Example:-     select * from employee
                       order by salary desc offset n
                       fetch next 1 only

Here we used the offset which mean it will left the record and it will give the next record like we put offset 3 then it will left the top three (3) record and it will give the 4th record. in this process we can also find the nth highest salary without using top () function.

how to find nth highest salary| max salary different ways ?

nth highest salary,highest salary,max,
                                                     1.how to find nth highest salary| max salary
                                                                                                       different ways

How to find max salary
 Syntax:- select max(col_name) from table_name
 Example:select max(salary) from employee   

How to find 2nd highest salary
Example:- select max(salary) from employee
                   where salary<(select max(salary) from employee)

How to find top 2 highest salary
Example:- select distinct top 2 salary
                  from employee
                  order by salary desc

How to find nth highest salary using sub query
Example:- select top 1 salary from 
                  (select distinct top 1 salary
                   from employee
                   order by salary desc)
                   result
                   order by salary 

Here we used the sub query to find the nth highest salary but above query gives the top first salary but you needs 2nd,3nd,4nd,5nd...............salary we need to modify the query like this.you need 3nd highest salary then put  distinct top 3.....

 Example:-select top 1 salary from 
                   (select distinct top 1..(2nd,3nd,4nd,5nd....nth) salary
                   from employee
                   order by salary desc)
                   result
                   order by salary 


Friday, January 10, 2020

SQL language Element ?

SQL,element,datatype,identifiers,
                                                         1.SQL Language Element


SQL Language Element


  1. Identifiers

                      Names of database objects such as tables,views,columns,rows etc.    

      2. Datatypes      

                     
                      Define the type of data that is contain by columns.

      3.Constants


                      Symbols that represent specific data type.

      4.Operators


                      Perform arithmetic,comparison and logical operations.

      5.Function


                      There are two types of functions
                               1.Built-in function
                               2. User define  function

          1.Built-in Function

                                     Built-in  function is perform specific operations.in sql have only built-in                                               function.

          2.User define function 

                                     In this function user can create there own function but to create own function                                       they have some rules.

        6.clauses

                     Constituent component of statement and queries.
                      Example:- var clause

        7.Expression

                           Produce scalar values or tables containing of column and row of data.

        8. Queries

                       Retrieve the data based on specific criteria this is an important element of SQL.

        9.Statement

                          create database ABC
                     
                          create     :- SQL command
                          Database:-Database Keyword
                          ABC      :- User define object_name
                                                      

SEVER TYPE IN SSMS ( Sql Server Managment studio)

When you install the SQL Server management studio and then you want to connect with the SQL Server then there are four types of SQL servers ...