Here are the steps to install VirtualBox on your machine:
- Go to https://www.virtualbox.org/wiki/Downloads to download the latest version of VirtualBox for your operating system.
string[] names = new string[5];There are two ways you can assign values to an array. The first is to assign the values individually by specify the index of the array inside a square bracket. The index is the position of element in the array. Index starts with 0.
names[0] = "George"; names[1] = "James"; names[2] = "Arthur"; names[3] = "Eric"; names[4] = "Jennifer";
USE Northwind; GO CREATE PROCEDURE GetProductsAvgPrice AS SELECT AVG(UnitPrice) FROM Products; GO
using System.Web.Configuration; using System.Data.SqlClient; using System.Data;
USE Northwind; Grant EXEC ON OBJECT::dbo.GetProducts TO "NT AUTHORITY\NETWORK SERVICE"; GO
USE Northwind; Grant EXEC ON OBJECT::dbo.GetProducts TO "NT AUTHORITY\NETWORK SERVICE"; GO
INSERT INTO [dbo].[Customers] ([CustomerID], [CompanyName] ,[ContactName] ,[ContactTitle] ,[Address] ,[City] ,[Region] ,[PostalCode] ,[Country] ,[Phone] ,[Fax]) SELECT 'OPDS', CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax FROM Customers WHERE CustomerID = 'ALFKI'
SELECT City,Address FROM Customers UNION SELECT City,Address FROM Employees
SELECT c.ContactName, o.OrderID FROM Customers c FULL OUTER JOIN Orders o ON c.CustomerID=o.CustomerID ORDER BY c.ContactName
USE Northwind GO CREATE PROCEDURE dbo.updProduct( @ProductID int, @ProductName nvarchar(40), @SupplierID int = null, --default is null @CategoryID int = null, @QuantityPerUnit nvarchar(20) = null, @UnitPrice money = null, @UnitsInStock smallint = null, @UnitsOnOrder smallint = null, @ReorderLevel smallint = null, @Discontinued bit) AS UPDATE Products SET ProductName = @ProductName, SupplierID = @SupplierID, CategoryID = @CategoryID, QuantityPerUnit = @QuantityPerUnit, UnitPrice = @UnitPrice, UnitsInStock = @UnitsInStock, UnitsOnOrder = @UnitsOnOrder, ReorderLevel = @ReorderLevel, Discontinued = @Discontinued WHERE Products.ProductID = @ProductID GO
USE Northwind GO CREATE PROCEDURE dbo.delProduct @ProductID int AS DELETE FROM Products WHERE Products.ProductID = @ProductID GO
EXEC dbo.delProduct 78
using System.Web.Configuration; using System.Data.SqlClient; using System.Data;
string connectString = WebConfigurationManager.ConnectionStrings["NorthwindConnectionString"]. ConnectionString;
using (SqlConnection conn = new SqlConnection(connectString)) { conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "addProduct"; cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = conn; SqlParameter productName = new SqlParameter("@ProductName", "Teh"); productName.SqlDbType = SqlDbType.NVarChar; productName.Direction = ParameterDirection.Input; cmd.Parameters.Add(productName); SqlParameter supplerID = new SqlParameter("@SupplierID", 1); supplerID.SqlDbType = SqlDbType.Int; supplerID.Direction = ParameterDirection.Input; cmd.Parameters.Add(supplerID); SqlParameter categoryID = new SqlParameter("@CategoryID", 1); categoryID.SqlDbType = SqlDbType.Int; categoryID.Direction = ParameterDirection.Input; cmd.Parameters.Add(categoryID); SqlParameter quantityPerUnit = new SqlParameter("@QuantityPerUnit", "20 boxes of 12 oz."); quantityPerUnit.SqlDbType = SqlDbType.NVarChar; quantityPerUnit.Direction = ParameterDirection.Input; cmd.Parameters.Add(quantityPerUnit); SqlParameter unitPrice = new SqlParameter("@UnitPrice", 12.99); unitPrice.SqlDbType = SqlDbType.Money; unitPrice.Direction = ParameterDirection.Input; cmd.Parameters.Add(unitPrice); SqlParameter unitsInStock = new SqlParameter("@UnitsInStock", 6); unitsInStock.SqlDbType = SqlDbType.SmallInt; unitsInStock.Direction = ParameterDirection.Input; cmd.Parameters.Add(unitsInStock); SqlParameter reorderLevel = new SqlParameter("@ReorderLevel", 2); reorderLevel.SqlDbType = SqlDbType.SmallInt; reorderLevel.Direction = ParameterDirection.Input; cmd.Parameters.Add(reorderLevel); SqlParameter discontinued = new SqlParameter("@Discontinued", false); discontinued.SqlDbType = SqlDbType.Bit; discontinued.Direction = ParameterDirection.Input; cmd.Parameters.Add(discontinued); int rowsAffected = cmd.ExecuteNonQuery(); Response.Write(rowsAffected); }In the above code you add the parameters required by the addProduct stored procedure. You specify the name, type, and value. Then add it to command object's parameters list. Then you execute the ExecuteNonQuery() method because you are not get a resultset back or a scalar value. The ExecuteNonQuery() method returns an int value, usually the rows that were affected value.
USE Northwind GO CREATE PROCEDURE dbo.addProduct( @ProductName nvarchar(40), @SupplierID int = null, --default is null @CategoryID int = null, @QuantityPerUnit nvarchar(20) = null, @UnitPrice money = null, @UnitsInStock smallint = null, @UnitsOnOrder smallint = null, @ReorderLevel smallint = null, @Discontinued bit) AS INSERT INTO Products(ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, ReorderLevel, Discontinued) VALUES(@ProductName, @SupplierID, @CategoryID, @QuantityPerUnit, @UnitPrice, @UnitsInStock, @UnitsOnOrder, @ReorderLevel, @Discontinued) GO
EXEC dbo.addProduct @ProductName ='Teh', @SupplierID = DEFAULT, @CategoryID = DEFAULT, @QuantityPerUnit ='20 boxes x 12 oz.', @UnitPrice = 12.99, @UnitsInStock = 5, @UnitsOnOrder = 6, @ReorderLevel = DEFAULT, @Discontinued = 0
SELECT CompanyName, ContactName, ContactTitle,Region FROM Customers WHERE Region = NULL
SELECT CompanyName, ContactName, ContactTitle,Region FROM Customers WHERE Region IS NULL
SELECT CompanyName, ContactName, ContactTitle,Region FROM Customers WHERE Region != NULL
SELECT CompanyName, ContactName, ContactTitle,Region FROM Customers WHERE Region IS NOT NULL