Posts

Showing posts from January, 2022

Stored procedures with output parameters

ALTER proc [dbo].[sp_addEmployee] (   @name varchar(20),  @email nvarchar(20),   @depId int,   @returnname varchar(40) output   )  as   begin    insert into tblEmployees(empName,empEmail,empDepId) values(@name,@email,@depId) select @returnname =empEmail from tblEmployees where empId=IDENT_CURRENT('tblEmployees') end; Declare @returnvalue varchar(40) Execute sp_addEmployee 'ram','ram124@g.com',1, @returnvalue output; select @returnvalue;
Start Animation By default, all HTML elements have a static position, and cannot be moved. To manipulate the position, remember to first set the CSS position property of the element to relative, fixed, or absolute!

html

Hello World Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

Clustered and Non-Clustered indexes

  The following are the different types of indexes in SQL Server 1. Clustered 2. Nonclustered 3. Unique 4. Filtered 5. XML 6. Full Text 7. Spatial 8. Columnstore 9. Index with included columns 10. Index on computed columns Create tblEmployees table using the script below. CREATE TABLE  [tblEmployee] ( [Id]  int Primary Key , [Name]  nvarchar (50), [Salary]  int , [Gender]  nvarchar (10), [City]  nvarchar (50) ) Note that  Id  column is marked as  primary key . Primary key, constraint create  clustered indexes automatically  if no clustered index already exists on the table and a nonclustered index is not specified when you create the PRIMARY KEY constraint.  To confirm this ,  execute  sp_helpindex  tblEmployee, which will show a unique clustered index created on the  Id  column.  Now execute the following insert queries . Note that, the values for Id column are not in a sequential order....

Indexes in sql server

Image
  Why indexes? Indexes are used by queries to find data from tables quickly. Indexes are created on tables and views. Index on a table or a view, is very similar to  an index that we find in a book. If you don't have an index in a book, and I ask you to locate a specific chapter in that book, you will have to look at every  page starting from the first page of the book. On, the other hand, if you have the index, you lookup the page number of the chapter in the index, and  then directly go to that page number to locate the chapter. Obviously, the book index is helping to drastically reduce the time it takes to find the  chapter. In a similar way, Table and View indexes, can help the query to find data quickly. In fact, the existence of the right indexes, can  drastically improve the performance of the query. If there is no index to help the query, then the query engine, checks every row in the table from  the beginning to the end. This is called as Tabl...

Cascading referential integrity constraint

CREATE TABLE [dbo].[tblDepartment]( [depId] [int] NOT NULL, [depName] [nvarchar](20) NOT NULL ); CREATE TABLE [dbo].[tblEmployees]( [empId] [int] IDENTITY(1,1) NOT NULL, [empName] [nvarchar](20) NOT NULL, [empEmail] [nvarchar](20) NULL, [empDepId] [int] NULL ); INSERT [dbo].[tblDepartment] ([depId], [depName]) VALUES (1, 'ECE'); INSERT [dbo].[tblDepartment] ([depId], [depName]) VALUES (2, 'CSE'); INSERT [dbo].[tblDepartment] ([depId], [depName]) VALUES (3, 'IT');  INSERT [dbo].[tblEmployees] ([empId], [empName], [empEmail], [empDepId]) VALUES (1, 'datta', 'kumar@g.com', 3); INSERT [dbo].[tblEmployees] ([empId], [empName], [empEmail], [empDepId]) VALUES (3, 'Teja', 'teja@g.com', 1); --set default ALTER TABLE tblEmployees ADD CONSTRAINT df_DepId DEFAULT 1 FOR empDepId; delete from tblDepartment where depId=3; 1. No Action : This is the default behaviour. No Action specifies that if an attempt is made to delete or update ...

sql union and union all

  UNION and UNION ALL operators in SQL Server, are used to combine the result-set of two or more   SELECT queries. Please consider India and UK customer tables below create table tblindiacustomers( id int primary key identity(1,1), name varchar(29), email varchar(30) ); create table tblUSAcustomers( id int primary key identity(1,1), name varchar(29), email varchar(30) ); insert into tblindiacustomers values ('Ram','ram@g.com'), ('Ravi','ravi@g.com'), ('Divya','divya@g.com'); insert into tblUSAcustomers values ('John','john@g.com'), ('Ravi','ravi@g.com'), ('michale','michale@g.com'); select id,name,email from tblindiacustomers union all select id,name,email from tblusacustomers; select id,name,email from tblindiacustomers union select id,name,email from tblusacustomers;