Posts

Showing posts with the label SQL SERVER

Difference between Delete and Truncate in sql server

T he  difference  between  DELETE   and  TRUNCATE   in  Sql Server  is one of the most important   interview questions   asked to freshers. I have tried to explain it here so that freshers can  better understand  the difference between these two. DELETE The DELETE command is used to remove rows from  a table . A WHERE clause can be used to delete specified records based on conditions. If no WHERE condition is specified, all rows will be removed. After performing a DELETE operation you need to COMMIT or ROLLBACK the transaction to make the change permanent or to undo it. It removes rows from a table or view. DELETE statements delete rows one at a time, logging each row in the transaction log, as well as maintaining log sequence number (LSN) information. e.g.   delete from  employee  ;( this command will remove all the data from employeetable)   delete from employee where emp_id=100;(This command will remove only that row from employee table where emp_id=100); TRUNCA

Differences between Stored procedures and Functions in Sql Server

Stored Procedure: A stored  procedure  is a   pre-compiled   group of Transact-SQL statements .We can say a storedprocedure is a prepared SQL code that we save so that we can reuse the code over and over again.    If a repetitive T-SQL task has to be executed within  an application , then the best way for it is to create   stored procedure. It is always recommended to create Stored Procedure instead of writing Inline queries so that we can just call the  Stored Procedures  whenever required instead of writing Inline queries again and again each time. You can also pass parameters to the stored procedure, so depending on  what the  need is the stored   procedure can act accordingly based on the parameter values that were passed to it. Function:  Function in Sql Server is a Transact-SQL or common language runtime (CLR) routine that takes  parameters, performs an action, and returns the result of that action as a value. The return value can either be a scalar (single) value o

Interview Questions in ASP.NET,C#.NET,SQL Server

Why would you like to change the company? 1) I am looking for a more challenging career in a firm with a larger employee base such as yours. 2) Keeping in mind my career goals, the time has come for me to move onto the next rung of  the ladder and make a mark for myself. This can be achieved in a company like this. 3) It is just a career move to enhance my knowledge in my own area of interest. After completion of this question only interview will go for further questions Difference between stored procedure and function 1) Procedure can return zero or n values whereas function can return one value which is mandatory. 2) Procedures can have input, output parameters for it whereas functions can have only input parameters. 3) Procedure allows select as well as DML statement in it whereas function allows only select statement in it. 4) Functions can be called from procedure whereas procedures cannot be called from function. 5) Exception can be handled by try-catch block