Posts

Pivot table in sql Server

A Pivot Table can automatically sort, count, and total the data stored in one table or spreadsheet and create a second table displaying the summarized data. The PIVOT operator turns the values of a specified column into column names, effectively rotating a table. You can use the PIVOT and UNPIVOT relational operators to change a table-valued expression into another table. PIVOT rotates a table-valued expression by turning the unique values from one column in the expression into multiple columns in the output, and performs aggregations where they are required on any remaining column values that are wanted in the final output.  UNPIVOT performs the opposite operation to PIVOT by rotating columns of a table-valued expression into column values. But we will see UNPIVOT afterwords. Example : Table Design : VendorId         nvarchar(50) IncomeDay nvarchar(50) IncomeAmount int Insert Some Data : insert into testdb1.dbo.DailyInco...

How to retrieve last 6 months data in sql server

How to retrieve last n months data in sql server ? Query :   SELECT *   FROM [db1].[dbo].[Data]   where  entry_date >= dateadd(mm,datediff(mm,0,getdate())- 6 ,0) Parameter :  Pink color marked data object worked as n number of months . Output : Display last 6 months data from current date.

How to retrieve Year / Month from Current or Any Datetime in SQL Server

Session 2 : How to retrieve Year / Month from Current or Any Datetime ? select  [YEAR] = YEAR(getdate()) ,[YEAR] = DATEPART(YY,getdate())  ,[MONTH] = month(getdate()) ,[MONTH] = DATEPART(mm,getdate()) ,[MONTH NAME] = DATENAME(mm, getdate()) Output : - YEAR YEAR MONTH    MONTH MONTH NAME 2013 2013 3            3                 March

System operations in C#

          System.Diagnostics.Process The  Process  class provides functionality to monitor system processes across the network, and to start and stop local system processes. In additional to retrieving lists of running processes (by specifying either the computer, the process name, or the process ID) or viewing information about the process that currently has access to the processor, you can get detailed knowledge of process threads and modules both through the  Process  class itself, and by interacting with the ProcessThread  and  ProcessModule  classes. The  ProcessStartInfo  class enables you to specify a variety of elements with which to start a new process, such as input, output, and error streams, working directories, and command line verbs and arguments. These give you fine control over the behavior of your processes. Other related classes let you specify window styles, process and thread prioritie...

ObjectDataSource in asp.net

Image
ASP.NET 2.0 ships with five built-in data source controls –  SqlDataSource ,  AccessDataSource ,  ObjectDataSource ,  XmlDataSource , and  SiteMapDataSource  – although you can build your own  custom data source controls , if needed. Since we have developed an architecture for our tutorial application, we'll be using the ObjectDataSource against our BLL classes. Step 1: Adding and Configuring the ObjectDataSource Control Start by opening the  SimpleDisplay.aspx  page in the  BasicReporting  folder, switch to Design view, and then drag an ObjectDataSource control from the Toolbox onto the page's design surface. The ObjectDataSource appears as a gray box on the design surface because it does not produce any markup; it simply accesses data by invoking a method from a specified object. The data returned by an ObjectDataSource can be displayed by a data Web control, such as the GridView, DetailsView, FormView, and so on. Note...

User control in asp.net with Example

User control is powerful functionality of ASP.NET. With the help of the user control you can reuse the Design as well as code in the application. Developing User control is similar to developing form in ASP.NET. User control is created in markup file with .ascx extension. We create two user control one for collect the user information and second for Display the user information. Step 1:   Add the Web user control in your form with the name MyControl.ascx ( .ascx is extension for user-control) ASCX code : <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MyControl.ascx.cs" Inherits="UserControlDemo.MyControl" %> <asp:TextBox ID="textNumber" runat="server"      ReadOnly="True" Width="32px" Enabled="False" /> <asp:Button Font-Bold="True" ID="buttonUp" runat="server"       Text="^" OnClick="buttonUp_Cl...

NameValueCollection with Example in C#

NameValueCollection collection is based on the  NameObjectCollectionBase  class. However, unlike the NameObjectCollectionBase, this class stores multiple string values under a single key. This class can be used for headers, query strings and form data. Each element is a key/value pair. Collections of this type do not preserve the ordering of element, and no particular ordering is guaranteed when enumerating the collection. The capacity of a  NameValueCollection  is the number of elements the  NameValueCollection  can hold. As elements are added to a  NameValueCollection , the capacity is automatically increased as required through reallocation. Aspx :     <table width="100%">         <tr>             <td align ="center">                 <table width ="50%">             ...