Thursday, March 21, 2013

Count Day In Sql Server

DECLARE @StartDate DATETIME
DECLARE @EndDate DATETIME
SET @StartDate = '2008/10/01'
SET @EndDate = '2008/10/31'


SELECT
   (DATEDIFF(dd, @StartDate, @EndDate) + 1)
  -(DATEDIFF(wk, @StartDate, @EndDate) * 2)
  -(CASE WHEN DATENAME(dw, @StartDate) = 'Sunday' THEN 1 ELSE 0 END)
  -(CASE WHEN DATENAME(dw, @EndDate) = 'Saturday' THEN 1 ELSE 0 END)

Monday, March 4, 2013

Add Body Class Just For IE

<!DOCTYPE html>
<!--[if IEMobile 7 ]> <html dir="ltr" lang="en-US"class="no-js iem7"> <![endif]-->
<!--[if lt IE 7 ]> <html dir="ltr" lang="en-US" class="no-js ie6 oldie"> <![endif]-->
<!--[if IE 7 ]>    <html dir="ltr" lang="en-US" class="no-js ie7 oldie"> <![endif]-->
<!--[if IE 8 ]>    <html dir="ltr" lang="en-US" class="no-js ie8 oldie"> <![endif]-->
<!--[if (gte IE 9)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html dir="ltr" lang="en-US" class="no-js"><!--<![endif]-->

Change Text Selection Color

/* Mozilla based browsers */
::-moz-selection {
       background-color: #FFA;
       color: #000;
}

/* Works in Safari */
::selection {
       background-color: #FFA;
       color: #000;
}

Top 10 Features in ASP.NET 4.5

1 - Bundling and Minification Feature
The newly introduced bundling and minification feature helps to bundle and minimize the size of the scripts and style sheets in your application. This feature has a great impact on the performance of your web application as a whole. You now have a System.Web.Optimization namespace that provides support for bundling and minification of files. Once you create a new project in ASP.NET 4.5, you'll notice these lines in your Global.asax file:
protected void Application_Start()
{
 //Some code
 BundleTable.Bundles.RegisterTemplateBundles();
}
 

2 - Strongly Typed Data Controls
In ASP.NET 4.5, you now have data controls that can be strongly typed. You will get intellisense - you just need to assign the ItemType property to a model that is going to be associated with the data controls used in your .aspx pages. Here is a snippet of code that illustrates how you can use this:
<asp:TemplateField HeaderText="Name" >     <ItemTemplate>           <%# Item.Name.ToString() %>     </ItemTemplate> </asp:TemplateField>


3 - Model Binding - Isolating the Web Form from the Model
The Model binding feature in ASP.NET 4.5 enables you to develop Webforms that are independent of the Model that populates the view. The biggest advantage of using Model Binding in ASP.NET is that you can easily unit test the methods. In ASP.NET 4.5 support for model binding is provided through the usage of the  ‘System.Web.ModelBinding’ namespace. This namespace contains value provider classes like ControlAttribute, QueryStringAttribute, etc. All these classes are inherited from the ValueProviderSourceAttribute class.



4 - Value Providers
ASP.NET4.5 provides many Value Providers that can be used to filter data. These are:
  • Querystring
  • Session
  • Cookie
  • Control Value
You can also have your own custom value providers.


5 - Support for OpenID in OAuth Logins
ASP.NET 4.5 provides support for OpenID for OAuth logins - you can easily use external services to login to your application. Like ASP.NET MVC 4, ASP.NET 4.5 enables you to register OAuth provider in the App_Start/AuthConfig.cs file. We can also use this data dictionary to pass additional data.
6 - Support for improved paging in ASP.NET 4.5 GridView control
Paging support in ASP.NET 4.5 GridView control has been improved a lot. ASP.NET 4.5 GridView.AllowCustomPaging property provides great support for paging and sorting through large amounts of data efficiently.
7 - Enhanced support for asynchronous programming
ASP.NET 4.5 provides excellent support in asynchronous programming - you can now read and write HTTP requests and responses without the need of OS threads. Also, you have support for two new keywords - await and async.
8 - Support for web sockets
HTML5 WebSockets allow you to perform duplex communication between the client browser and the web server. ASP.NET 4.5 provides support for web socket protocols. ASP.NET 4.5 and IIS 8 provide support for WebSocket protocol - you can now leverage WebSockets in your ASP.NET web applications. You can learn more on this from this link
Support for web sockets is provided through the System.Net.WebSockets namespace.

9 - Support for HTML5 form types
ASP.NET 4.5 provides excellent support for HTML5 form types. The following are the list of new controls available in HTML5:
  • email
  • url
  • number
  • range
  • Date pickers i.e., date, month, week, time, datetime, datetime-local
  • search
  • color
10 - ASP.NET Web API
This is included in ASP.NET MVC 4 and ASP.NET Web Forms. This new ASP.NET Web API helps you to build and consume HTTP services easily.



 

Top Features of SQL Server 2012

1. AlwaysOn Availability Groups -- This feature takes database mirroring to a whole new level. With AlwaysOn, users will be able to fail over multiple databases in groups instead of individually. Also, secondary copies will be readable, and can be used for database backups. The big win is that your DR environment no longer needs to sit idle.

2. Windows Server Core Support -- If you don't know what Windows Server Core is, you may want to come up to speed before Windows 8 (MS is making a push back to the command line for server products). Core is the GUI-less version of Windows that uses DOS and PowerShell for user interaction. It has a much lower footprint (50% less memory and disk space utilization), requires fewer patches, and is more secure than the full install. Starting with SQL 2012, it is supported for SQL Server.

3. Columnstore Indexes -- This a cool new feature that is completely unique to SQL Server. They are special type of read-only index designed to be use with Data Warehouse queries. Basically, data is grouped and stored in a flat, compressed column index, greatly reducing I/O and memory utilization on large queries.
4. User-Defined Server Roles -- DBAs have always had the ability to create custom database role, but never server wide. For example, if the DBA wanted to give a development team read/write access to every database on a shared server, traditionally the only ways to do it were either manually, or using undocumented procedures. Neither of which were good solutions. Now, the DBA can create a role, which has read/write access on every DB on the server, or any other custom server wide role.

5. Enhanced Auditing Features -- Audit is now available in all editions of SQL Server. Additionally, users can define custom audit specifications to write custom events into the audit log. New filtering features give greater flexibility in choosing which events to write to the log.

6. BI Semantic Model -- This is replacing the Analysis Services Unified Dimensional Model (or cubes most people referred to them). It's a hybrid model that allows one data model will support all BI experiences in SQL Server. Additionally, this will allow for some really neat text infographics

7. Sequence Objects -- For those folks who have worked with Oracle, this has been a long requested feature. A sequence is just an object that is a counter -- a good example of it's use would be to increment values in a table, based a trigger. SQL has always had similar functionality with identity columns, but now this is a discrete object.

8. Enhanced PowerShell Support -- Windows and SQL Server admins should definitely start brushing up on their PowerShell scripting skills. Microsoft is driving a lot of development effort into instrumenting all of their server-based products with PowerShell. SQL 2008 gave DBAs some exposure to it, but there are many more in cmdlets in SQL 2012.

9. Distributed Replay -- Once again this is answer to a feature that Oracle released (Real Application Testing). However, and in my opinion where the real value proposition of SQL Server is, in Oracle it is a (very expensive) cost option to Enterprise Edition. With SQL, when you buy your licenses for Enterprise Edition, you get everything. Distributed replay allows you to capture a workload on a production server, and replay it on another machine. This way changes in underlying schemas, support packs, or hardware changes can be tested under production conditions.

10. PowerView -- You may have heard of this under the name "Project Crescent" it is a fairly powerful self-service BI toolkit that allows users to create mash ups of BI reports from all over the Enterprise.
11. SQL Azure Enhancements -- These don't really go directly with the release of SQL 2012, but Microsoft is making some key enhancements to SQL Azure. Reporting Services for Azure will be available, along with backup to the Windows Azure data store, which is a huge enhancement. The maximum size of an Azure database is now up to 150G. Also Azure data sync allows a better hybrid model of cloud and on-premise solutions

12. Big Data Support -- I saved the biggest for last, introduced at the PASS (Professional Association for SQL Server) conference last year, Microsoft announced a partnership with Hadoop provider Cloudera. One part of this involves MS releasing a ODBC driver for SQL Server that will run on a Linux platform. Additionally, Microsoft is building connectors for Hadoop, which is an extremely popular NoSQL platform. With this announcement, Microsoft has made a clear move into this very rapidly growing space.

Top 5 New Features in Visual Studio 2012

  1. Metro UI Development Support  – Visual Studio 2012 includes support for new project templates for building Metro UI apps for multiple devices and Windows 8.  Support includes XAML, C#, VB, and HTML5/Javascript apps.  If you want to build a Windows 8 app, you might need to run VS 2012 on Windows 8 for WinRT support.
  2. Game Development Support  – Game development support is included in Visual Studio including first rate debugging of multithreaded XNA games.  It also includes visual designers for 2D and 3D gaming.
  3. Semantic Code Analysis  – Visual Studio 2012 has come a long way from FxCop.  Code Analysis features in VS 2012 include semantic code analysis, i.e. not just syntax but the actual logic of your code.  This allows for better refactoring including my personal favorite feature, finding copy/paste code and refactoring to use inheritance.
  4. Team Development Improvements - Many of the new features for teams center around the upcoming Team Foundation Server 2012 release.  These include performing code reviews, an enhanced diff tool, and offline workspaces.  There have also been some very nice improvements in Agile/Scrum management with the new TFS Scrum Project template.
  5. HTML5/CSS3 Support – Visual Studio 2012 includes support for HTML5 and CSS3 for both Metro UI apps as well as web based applications.  Of course VS 2012 will include ASP.NET MVC4 and Razor support.  But perhaps best of all is the improved support for Javascript including Intellisense and debugging features.

The markup

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Smashing HTML5!</title>
 
<link rel="stylesheet" href="css/main.css" type="text/css" />
 
<!--[if IE]>
 <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<!--[if lte IE 7]>
 <script src="js/IE8.js" type="text/javascript"></script><![endif]-->
<!--[if lt IE 7]>
 
 <link rel="stylesheet" type="text/css" media="all" href="css/ie6.css"/><![endif]-->
</head>
 
<body id="index" class="home">
</body>
</html>

Opps Part 1 : Abstraction

  Abstraction in C# is a fundamental concept of object-oriented programming (OOP) that allows developers t...