2
Reply

Interview question answer in sql

Pooja Singh

Pooja Singh

8y
402
0
Reply

    If you are looking for SQL interview , you can refer this featured article link. ---------------------------------------------------------------------------------------------------------- http://www.c-sharpcorner.com/article/most-asked-sql-queries-in-interview-questions/

    *) what is transaction & how to use in sql. Ans - A transaction is a set of operations performed so all operations are guaranteed to succeed or fail as one unit. 1. BEGIN TRANSACTION trans 2. BEGIN TRY 3. INSERT INTO Department(DeptID,DeptName,Location)VALUES(2,'HR','Delhi') 4. INSERT INTO Employee(EmpID,Name,Salary,Address,DeptID)VALUES(1,'Mohan',18000,'Delhi',1) 5. IF @@TRANCOUNT > 0 6. BEGIN COMMIT TRANSACTION trans 7. END 8. END TRY 9. BEGIN CATCH 10. print 'Error Occured' 11. IF @@TRANCOUNT > 0 12. BEGIN ROLLBACK TRANSACTION trans 13. END 14. END CATCH what is difference b\w unique key and primary key. --unique key can have nulls but primary keys cannot have nulls. --We have multiple unique key in one table but only one primary key have one table. --Unique create non cluster index by default but primary key creates a clustered index by default. *) what is entity framework & benefit.Ans- ADO.NET entity is an ORM (object relational mapping) which creates a higher abstract object model over ADO.NET components. So rather than getting into dataset, datatables, command, and connection objects as shown in the below code, you work on higher level domain objects like customers, suppliers, etc The main and the only benefit of EF is it auto-generates code for the Model (middle layer), Data Access Layer, and mapping code, thus reducing a lot of development time. • How to merge two dataset.Ans- You can merge two or more Dataset objects that have largely similar schemas to exist in the same Data Container. In my case, I have two database tables and I want to display all records from both tables in a single Data Container. For this we can use the Merge() method in C#. Rules to display two Datasets in a Grid View: • All the columns specified in the data grid must be present in both datasets. • The data type of all columns in the datasets must be the same. • The column names should match. EXAMPLE- Dataset 1=dt1; Dataset2=dt2; Dt1.merge(dt2);