Search This Blog

Lets go..




Manage your Inventory | Grow your restaurant business | Manage your Employee | Control your accounts

Sunday

SQL exam 70-461 questions and answers part 1


MS SQL exam 70-461 questions and answers dumps

QUESTION 1
You develop a Microsoft SQL Server 2012 server database that supports an application. The Application contains a table that has the following definition:

CREATE TABLE Inventory (
ItemID int NOT NULL PRIMARY KEY,
ItemsInStore int NOT NULL,
ItemsInWarehouse int NOT NULL)

You need to create a computed column that returns the sum total of the ItemsInStore and ItemsInWarehouse values for each row. The new column is expected to be queried heavily, and you need to be able to index the column. Which Transact-SQL statement should you use?

A. ALTER TABLE Inventory
ADD TotalItems AS ItemslnStore + ItemsInWarehouse
B. ALTER TABLE Inventory
ADD TotalItems AS ItemsInStore + ItemsInWarehouse PERSISTED
C. ALTER TABLE Inventory
ADD TotalItems AS SUM(ItemsInStore, ItemsInWarehouse) PERSISTED
D. ALTER TABLE Inventory
ADD TotalItems AS SUM(ItemsInStore, ItemsInWarehouse)



QUESTION 2
You develop a Microsoft SQL Server 2012 server database that supports an application. The application contains a table that has the following definition:

CREATE TABLE Inventory
(ItemID int NOT NULL PRIMARY KEY,
ItemsInStore int NOT NULL,
ItemsInWarehouse int NOT NULL)

You need to create a computed column that returns the sum total of the ItemsInStore and
ItemsInWarehouse values for each row. Which Transact-SQL statement should you use?

A. ALTER TABLE Inventory
ADD TotalItems AS ItemsInStore + ItemsInWarehouse
B. ALTER TABLE Inventory
ADD ItemsInStore - ItemsInWarehouse = TotalItems
C. ALTER TABLE Inventory
ADD TotalItems = ItemsInStore + ItemsInWarehouse
D. ALTER TABLE Inventory
ADD TotalItems AS SUM(ItemsInStore, ItemslnWarehouse);



QUESTION 3
You develop a Microsoft SQL Server 2012 database. You create a view that performs the following tasks:

Ÿ Joins 8 tables that contain up to 500,000 records each.
Ÿ Performs aggregations on 5 fields.

The view is frequently used in several reports. You need to improve the performance of the reports.
What should you do?

A. Convert the view into a table-valued function.
B. Convert the view into a Common Table Expression (CTE).
C. Convert the view into an indexed view.
D. Convert the view into a stored procedure and retrieve the result from the stored procedure
into a temporary table.



QUESTION 4
You have an XML schema collection named Sales.InvoiceSchema. You need to declare a variable of
the XML type named XML1. The solution must ensure that XML1 is validated by using Sales.InvoiceSchema. Which code segment should you use?

To answer, type the correct code in the answer area.

Correct Answer:
DECLARE @XML1 XML(Sales.InvoiceSchema)



QUESTION 5
You use Microsoft SQL Server 2012 database to develop a shopping cart application. You need to invoke a table-valued function for each row returned by a query.

Which Transact-SQL operator should you use?

A. CROSS JOIN
B. UNPIVOT
C. PIVOT
D. CROSS APPLY



QUESTION 6
You are developing a database that will contain price information. You need to store the prices that Include a fixed precision and a scale of six digits. Which data type should you use?

A. Float
B. Money
C. Smallmoney
D. Numeric
 


QUESTION 7
You develop three Microsoft SQL Server 2012 databases named Database1, Database2, and  Database3. You have permissions on both Database1 and Database2. You plan to write and deploy a stored procedure named dbo.usp_InsertEvent in Database3. dbo.usp_InsertEvent must execute other stored procedures in the other databases. You need to ensure that callers that do not have permissions on Database1 or Database2 can execute the stored procedure. Which Transact-SQL statement should you use?

A. USE Database2
B. EXECUTE AS OWNER
C. USE Database1
D. EXECUTE AS CALLER



QUESTION 8
You develop a Microsoft SQL Server 2012 database that contains tables named Customers and Orders. The tables are related by a column named CustomerId . You need to create a query that meets the following requirements:

Ÿ Returns the CustomerName for all customers and the OrderDate for any orders that they have placed.
Ÿ Results must not include customers who have not placed any orders.
Which Transact-SQL query should you use?

A. SELECT CustomerName, OrderDate
FROM Customers
LEFT OUTER JOIN Orders
ON Customers.CuscomerlD = Orders.CustomerId

B. SELECT CustomerName, OrderDate
FROM Customers
RIGHT OUTER JOIN Orders
ON Customers.CustomerID = Orders.CustomerId
C. SELECT CustomerName, OrderDate
FROM Customers
CROSS JOIN Orders
ON Customers.CustomerId = Orders.CustomerId
D. SELECT CustomerName, OrderDate
FROM Customers
JOIN Orders
ON Customers.CustomerId = Orders.CustomerId




QUESTION 9
You have a Microsoft SQL Server 2012 database that contains tables named Customers and Orders. The tables are related by a column named CustomerID. You need to create a query that meets the following requirements:
Ÿ Returns the CustomerName for all customers and the OrderDate for any orders that they have placed.
Ÿ Results must include customers who have not placed any orders.

Which Transact-SQL query should you use?

A. SELECT CustomerName, OrderDate
FROM Customers
RIGHT OUTER JOIN Orders
ON Customers.CustomerID = Orders.CustomerID
B. SELECT CustomerName, CrderDate
FROM Customers
JOIN Orders
ON Customers.CustomerID = Orders.CustomerID
C. SELECT CustomerName, OrderDate
FROM Customers
CROSS JOIN Orders
ON Customers.CustomerID = Orders.CustomerID
D. SELECT CustomerName, OrderDate
FROM Customers
LEFT OUTER JOIN Orders
ON Customers.CustomerID = Orders.CustomerID



QUESTION 10

The procedure can be called within other transactions. You need to ensure that when the DELETE statement from the HumanResourcesJobCandidate table succeeds, the modification is retained even if the insert into the Audit.Log table fails.
Which code segment should you add to line 14?

A. IF @@TRANCOUNT = 0
B. IF (XACT_STATE ( ) ) = 0
C. IF (XACT_STATE ( ) ) = 1
D. IF @@TRANCOUNT = l
 ===========================================================================

Correct Answer:

1
2
3
4
5
6
7
8
9
10
B
A
C

D
D
B
D
D
C

Thursday

How to Create web service using Database and How to Consume web service in ASP.NET



How to Create web service using Database and How to Consume web service.
Previous Web service -->  Series

  1.  How to use web service  or how to consume web service using ASP.NET
  2.  How To create Web service and Consume in web page using ASP.NET
Requirement
1. SQL server 2008 - upper
2. Visual Studio 2010 - upper

Introduction 
Welcome to web service learning. Today our learning is Database + web Service = Database web service.
I am discussing about how to create web service for use SQL server database table data sample and use into any web page.
I am using sample Database Northwind.mdf Data Sample. Northwind database is available for download.

Procedure
First Create a Store procedure using [Employees] table which name SP_EmployeesInfo
 
Our SP is ready to use into web service file .asmx [WebService.cs]
Here is the main web service Method EmployeesInfoFromDatabase.

[WebMethod]
    public DataSet EmployeesInfoFromDatabase(string value)
    {
        String  ConnectionString =         ConfigurationManager.ConnectionStrings["connectionStr"].ConnectionString;
        SqlConnection con = new SqlConnection(ConnectionString);
        SqlCommand cmd = new SqlCommand("SP_EmployeesInfo", con);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@value", value);
        SqlDataAdapter adap = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        adap.Fill(ds);
        return ds;          // Return whole table
        ////
        //string domname = ds.Tables[0].Rows[1].ItemArray[1].ToString();
        // return DataSet ds.Tables[0].Rows[1].ItemArray[1].ToString();
    }
Now Run it our web service is ready to use.

How to Consume web service ?
It’s database dependent web service so we have to assign DB name, UID into connection String so Please open web.config file and provide your Database name , User ID , Password.
<add name="connectionStr" connectionString="Data Source=(local);Initial Catalog=Northwind;Persist Security Info=True;User ID=sa;Password=sapass123!" providerName="System.Data.SqlClient"/>


Add web Reference
Now Copy the web service URL   
http://localhost:55011/WebServiceWithDB/WebService.asmx
Add web Reference --> paste Link into URL textbox

or
 follow our previous Article how consume web service

Now add a web page
In Default.aspx page add one textbox , button and a label.
This is the button event code. 

protected void BtnSave_Click(object sender, EventArgs e)
    {
        DatabaseWebservice.WebService DBWS = new DatabaseWebservice.WebService();
        //create our DataSet to hold the member information returned
        DataSet dsMembers = new DataSet();
      
        //set our DataSet to the GetAllUsers Method of our web service
        dsMembers = DBWS.EmployeesInfoFromDatabase(txtEmpID.Text);

       //// grdviewuserDetails.AutoGenerateColumns = true;
        grdviewuserDetails.EmptyDataText = "No Records Found";
        grdviewuserDetails.DataSource = dsMembers.Tables[0].DefaultView; // dsMembers..ExecuteReader();
       grdviewuserDetails.DataMember = "value";
        grdviewuserDetails.DataBind();      
        // return only cell
        //mydataset.Tables[0].Rows[i]["id"].ToString();
        lblName.Text = dsMembers.Tables[0].Rows[0][1].ToString();  
    }
 

Now your project is ready to use press F5 .
Parameter value is = Nancy, Andrew  or London

Conclusion 
This is database dependent web service. User can create any DB web service. This sample help you to solve any complex problem. Users can consume this one any dynamic web project. OK good bye.
Hope to hear from you soon.