What is normalization?
Normalization is the basic concept used in designing a database. Its nothing but, an advise given to the database to have minimal repetition of data, highly structured, highly secured, easy to retrieve. In high level definition, the Process of organizing data into tables is referred to as normalization.
What is a stored procedure:
Stored procedures are precompiled T-SQL statements combined to perform a single task of several tasks. Its basically like a Macro so when you invoke the Stored procedure, you actually run a set of statements. As, its precompiled statement, execution of Stored procedure is compatatively high when compared to an ordinary T-SQL statement.
What is the difference between UNION ALL Statement and UNION ?
The main difference between UNION ALL statement and UNION is UNION All statement is much faster than UNION,the reason behind this is that because UNION ALL statement does not look for duplicate rows, but on the other hand UNION statement does look for duplicate rows, whether or not they exist.
Example for Stored Procedure?
They are three kinds of stored procedures,1.System stored procedure – Start with sp_2. User defined stored procedure – SP created by the user.3. Extended stored procedure – SP used to invoke a process in the external systems.Example for system stored proceduresp_helpdb - Database and its propertiessp_who2 – Gives details about the current user connected to your system. sp_renamedb – Enable you to rename your database
What is a trigger?
Triggers are precompiled statements similar to Stored Procedure. It will automatically invoke for a particular operation. Triggers are basically used to implement business rules.
What is a view?
If we have several tables in a db and we want to view only specific columns from specific tables we can go for views. It would also suffice the needs of security some times allowing specfic users to see only specific columns based on the permission that we can configure on the view. Views also reduce the effort that is required for writing queries to access specific columns every time.
What is an Index?
When queries are run against a db, an index on that db basically helps in the way the data is sorted to process the query for faster and data retrievals are much faster when we have an index.
What are the types of indexes available with SQL Server?
There are basically two types of indexes that we use with the SQL ServerClustered -
1. It will format the entire table, inturn physically sort the table.
2. Only one clustered index can be created for a table.
3. Data will be located in the leaf level.
4. By default, primary key will create clustered index on the table.
Non-Clustered Index
1. It wont touch the structure of the table.
2. It forms an index table as reference to the exact data.
3. A reference to the data will be located in the leaf level.
4. For a table, we can create 249 non clustered index.
Happy Learning!!!
Regards,
Venkatesan Prabu .J
2 comments:
hi, i to need to make my column name variable, i have code (see below) but i got error ("Incorrect syntax near the keyword 'from'.")
can you help me on this? thanks in advance... have a nice day
----code---------------------
use db_Treasury
go
declare @val01 varchar(10)
declare @val02 varchar(100)
set @val01 = 'colum1'
declare @val11 varchar(10)
declare @val12 varchar(100)
set @val11 = 'column2'
declare @val21 varchar(10)
declare @val22 varchar(100)
set @val21 = 'column3'
declare @val31 varchar(10)
declare @val32 varchar(100)
set @val31 = 'column4'
declare @val41 varchar(10)
declare @val42 varchar(100)
set @val41 = 'column5'
select
fld_CsAreaCd as Area,
(fld_CtFName + ' ' + fld_CtLName) as AC,
fld_csname as CLUSTER
set @val02 = 'case
when convert(char(10), fld_CrReqDate, 101) in (06/06/2009) then LTRIM(SUBSTRING(CONVERT(VARCHAR(20),
CONVERT(DATETIME, fld_CrReqDate), 22), 10, 5) + RIGHT(CONVERT(VARCHAR(20),
CONVERT(DATETIME, fld_CrReqDate), 22), 3)) end as '+ @val01 +' ' ---column1
exec(@val02)
set @val12 = 'case
when convert(char(10), fld_CrReqDate, 101) in (06/07/2009) then LTRIM(SUBSTRING(CONVERT(VARCHAR(20),
CONVERT(DATETIME, fld_CrReqDate), 22), 10, 5) + RIGHT(CONVERT(VARCHAR(20),
CONVERT(DATETIME, fld_CrReqDate), 22), 3)) end as '+ @val11 +' ' ---column2
exec(@val12)
set @val22 = 'case
when convert(char(10), fld_CrReqDate, 101) in (06/08/2009) then LTRIM(SUBSTRING(CONVERT(VARCHAR(20),
CONVERT(DATETIME, fld_CrReqDate), 22), 10, 5) + RIGHT(CONVERT(VARCHAR(20),
CONVERT(DATETIME, fld_CrReqDate), 22), 3)) end as '+ @val21 +' ' ---column3
exec(@val22)
set @val32 = 'case
when convert(char(10), fld_CrReqDate, 101) in (06/09/2009) then LTRIM(SUBSTRING(CONVERT(VARCHAR(20),
CONVERT(DATETIME, fld_CrReqDate), 22), 10, 5) + RIGHT(CONVERT(VARCHAR(20),
CONVERT(DATETIME, fld_CrReqDate), 22), 3)) end as '+ @val31 +' ' ----column4
exec(@val32)
set @val42 = 'case
when convert(char(10), fld_CrReqDate, 101) in (06/10/2009) then LTRIM(SUBSTRING(CONVERT(VARCHAR(20),
CONVERT(DATETIME, fld_CrReqDate), 22), 10, 5) + RIGHT(CONVERT(VARCHAR(20),
CONVERT(DATETIME, fld_CrReqDate), 22), 3)) end as '+ @val41 +' ' ----column5
exec(@val42)
from dbo.tbl_Contacts inner join
dbo.tbl_Cluster on
fld_CsClusterCd=fld_CtClusterCd
left join dbo.tbl_ClCashReq
on fld_CrClusterCd=fld_CsClusterCd
and fld_CrStatus >= '30'
and ((fld_CrReqDate >= '06/06/2009') and (fld_CrReqDate <= '06/10/2009'))
order by fld_csareacd, fld_CrReqDate asc
i want my column names to be variable.. i have code (see below) but a got an error in sql server 2005 saying "Incorrect syntax near the keyword 'from'."
can you help me on this error? thanks in advace.. have a nice day ahead....
-----code---
use db_Treasury
go
declare @val01 varchar(10)
declare @val02 varchar(100)
set @val01 = 'colum1'
declare @val11 varchar(10)
declare @val12 varchar(100)
set @val11 = 'column2'
declare @val21 varchar(10)
declare @val22 varchar(100)
set @val21 = 'column3'
declare @val31 varchar(10)
declare @val32 varchar(100)
set @val31 = 'column4'
declare @val41 varchar(10)
declare @val42 varchar(100)
set @val41 = 'column5'
select
fld_CsAreaCd as Area,
(fld_CtFName + ' ' + fld_CtLName) as AC,
fld_csname as CLUSTER
set @val02 = 'case
when convert(char(10), fld_CrReqDate, 101) in (06/06/2009) then LTRIM(SUBSTRING(CONVERT(VARCHAR(20),
CONVERT(DATETIME, fld_CrReqDate), 22), 10, 5) + RIGHT(CONVERT(VARCHAR(20),
CONVERT(DATETIME, fld_CrReqDate), 22), 3)) end as '+ @val01 +' ' ---column1
exec(@val02)
set @val12 = 'case
when convert(char(10), fld_CrReqDate, 101) in (06/07/2009) then LTRIM(SUBSTRING(CONVERT(VARCHAR(20),
CONVERT(DATETIME, fld_CrReqDate), 22), 10, 5) + RIGHT(CONVERT(VARCHAR(20),
CONVERT(DATETIME, fld_CrReqDate), 22), 3)) end as '+ @val11 +' ' ---column2
exec(@val12)
set @val22 = 'case
when convert(char(10), fld_CrReqDate, 101) in (06/08/2009) then LTRIM(SUBSTRING(CONVERT(VARCHAR(20),
CONVERT(DATETIME, fld_CrReqDate), 22), 10, 5) + RIGHT(CONVERT(VARCHAR(20),
CONVERT(DATETIME, fld_CrReqDate), 22), 3)) end as '+ @val21 +' ' ---column3
exec(@val22)
set @val32 = 'case
when convert(char(10), fld_CrReqDate, 101) in (06/09/2009) then LTRIM(SUBSTRING(CONVERT(VARCHAR(20),
CONVERT(DATETIME, fld_CrReqDate), 22), 10, 5) + RIGHT(CONVERT(VARCHAR(20),
CONVERT(DATETIME, fld_CrReqDate), 22), 3)) end as '+ @val31 +' ' ----column4
exec(@val32)
set @val42 = 'case
when convert(char(10), fld_CrReqDate, 101) in (06/10/2009) then LTRIM(SUBSTRING(CONVERT(VARCHAR(20),
CONVERT(DATETIME, fld_CrReqDate), 22), 10, 5) + RIGHT(CONVERT(VARCHAR(20),
CONVERT(DATETIME, fld_CrReqDate), 22), 3)) end as '+ @val41 +' ' ----column5
exec(@val42)
from dbo.tbl_Contacts inner join
dbo.tbl_Cluster on
fld_CsClusterCd=fld_CtClusterCd
left join dbo.tbl_ClCashReq
on fld_CrClusterCd=fld_CsClusterCd
and fld_CrStatus >= '30'
and ((fld_CrReqDate >= '06/06/2009') and (fld_CrReqDate <= '06/10/2009'))
order by fld_csareacd, fld_CrReqDate asc
Post a Comment