These are the industry-accepted standard naming conventions for J#, C# and VB.NET programs. For additional information, please see the MSDN help documentation and FX Cop. While individual naming conventions at organizations may vary (Microsoft only suggests conventions for public and protected items), the list below is quickly becoming the de-facto standard in the industry. Please note the absence of Hungarian Notation except in visual controls. These naming standards should find their way into all of your .NET development, including ASP.NET Web applications and .NET Windows Forms applications. Note that while this document predates the online and printed standards documentation from Microsoft, everything below which indicates it is based on .NET library standards is consistent with that documentation. In areas where Microsoft has not provided guidance (Microsoft generally doesn't care what you do in private/non-exposed code. In fact, they aren't even consistant in their internal code in the .NET framework), de facto standards have emerged, and I have captured them here. The "ux" naming convention for controls is something I have added and found to be helpful. It is not based on any official standards, but instead based upon a multitude of projects by my teams and others, as well as on-line discussions on the topic. While I strongly recommend that you follow Microsoft guidelines when present, I encourage you to try out the items marked as extensions below and see how they work for you before committing to them. Standard Based Upon Microsoft .NET Library Standards Pascal Case, no underscores. Use CompanyName.TechnologyName as root. If you don't have a company, use your domain name or your own initials. Note that any acronyms of three or more letters should be pascal case (Xml instead of XML) instead of all caps. Why: This convention is consistent with the .NET Framework and is easy to read. Standard Based Upon Microsoft .NET Library Standards If the assembly contains a single name space, or has an entire self-contained root namespace, name the assembly the same name as the namespace. Why: This convention is consistent with the .NET Framework and is easy to read. More importantly, however, it keeps your assembly names and namespaces lined up, making it really easy to figure out what is any particular assembly, and what assembly you need to reference for any given class. AppliedIS.TimeCard.BusinessRules.dll Standard Based Upon Microsoft .NET Library Standards Pascal Case, no underscores or leading "C" or "cls". Classes may begin with an "I" only if the letter following the I is not capitalized, otherwise it looks like an Interface. Classes should not have the same name as the namespace in which they reside. Any acronyms of three or more letters should be pascal case, not all caps. Try to avoid abbreviations, and try to always use nouns. Why: This convention is consistent with the .NET Framework and is easy to read. Widget Standard Based Upon Microsoft .NET Library Standards Follow class naming conventions, but add Collection to the end of the name Why: This convention is consistent with the .NET Framework and is easy to read. Standard Based Upon Microsoft .NET Library Standards Follow class naming conventions, but add Delegate to the end of the name Why: This convention is consistent with the .NET Framework and is easy to read. Standard Based Upon Microsoft .NET Library Standards Follow class naming conventions, but add Exception to the end of the name Why: This convention is consistent with the .NET Framework and is easy to read. Standard Based Upon Microsoft .NET Library Standards Follow class naming conventions, but add Attribute to the end of the name Why: This convention is consistent with the .NET Framework and is easy to read. Standard Based Upon Microsoft .NET Library Standards Follow class naming conventions, but start the name with "I" and capitalize the letter following the "I" Why: This convention is consistent with the .NET Framework and is easy to read. It also distinguishes classes from interfaces, where (unlike in VB6) are truly different beings. This avoid name collisions as well, as it is quite common to have IFoo and a class named Foo that implements IFoo. Standard Based Upon Microsoft .NET Library Standards Follow class naming conventions. Do not add "Enum" to the end of the enumeration name. If the enumeration represents a set of bitwise flags, end the name with a plural. Why: This convention is consistent with the .NET Framework and is easy to read. SearchOptions (bitwise flags) AcceptRejectRule (normal enum) Standard Based Upon Microsoft .NET Library Standards Pascal Case, no underscores except in the event handlers. Try to avoid abbreviations. Many programmers have a nasty habit of overly abbreviating everything. This should be discouraged. Functions and subs must differ by more than case to be usable from case-insensitive languages like Visual Basic .NET Why: This convention is consistent with the .NET Framework and is easy to read. VB: Public Sub DoSomething(...) C#: public void DoSomething(...) Standard Based Upon Microsoft .NET Library Standards Pascal Case, no underscores. Try to avoid abbreviations. Members must differ by more than case to be usable from case-insensitive languages like Visual Basic .NET. Why: This convention is consistent with the .NET Framework and is easy to read. VB: Public Property RecordID As Integer C#: public int RecordID Standard Based Upon Microsoft .NET Library Standards Camel Case. Try to avoid abbreviations. Parameters must differ by more than case to be usable from case-insensitive languages like Visual Basic .NET. Why: This convention is consistent with the .NET Framework and is easy to read. VB: ByRef recordID As Integer C#: ref int recordID Standard Based Upon De facto Industry-Accepted Practices Camel Case Why: This convention is consistent with the .NET Framework and is easy to read. It also avoids naming collisions with class-level variables (see below) VB: Dim recordID As Integer C#: int recordID ; Standard Based Upon De facto Industry-Accepted Practices Camel Case with Leading Underscore. In VB.NET, always indicate "Protected" or "Private", do not use "Dim". Use of "m_" is discouraged, as is use of a variable name that differs from the property by only case, especially with protected variables as that violates compliance, and will make your life a pain if you program in VB.NET, as you would have to name your members something different from the accessor/mutator properties. Of all the items here, the leading underscore is really the only controversial one. I personally prefer it over straight underscore-less camel case for my private variables so that I don't have to qualify variable names with "this." to distinguish from parameters in constructors or elsewhere where I likely will have a naming collision. With VB.NET's case insensitivity, this is even more important as your accessor properties will usually have the same name as your private member variables except for the underscore. As far as m_ goes, it is really just about aesthetics. I (and many others) find m_ ugly, as it looks like there is a hole in the variable name. It's almost offensive. I used to use it in VB6 all the time, but that was only because variables could not have a leading underscore. I couldn't be happier to see it go away. Microsoft recommends against the m_ (and the straight _) even though they did both in their code. Also, prefixing with a straight "m" is right out. Of course, since they code mainly in C#, they can have private members that differ only in case from the properties. VB folks have to do something else. Rather than try and come up with language-by-language special cases, I recommend the leading underscore for all languages that will support it. If I want my class to be fully CLS-compliant, I could leave off the prefix on any C# protected member variables. In practice, however, I never worry about this as I keep all potentially protected member variables private, and supply protected accessors and mutators instead. Why: In a nutshell, this convention is simple (one character), easy to read (your eye is not distracted by other leading characters), and successfully avoids naming collisions with procedure-level variables and class-level properties. VB: Private _recordID As Integer C#: private int _recordID ; An Extension to the Standards In recent projects (since 2002 or so), I have taken to a single prefix for all my UI controls. I typically use "ux" (I used to use "ui", but it wasn't set apart well in intellisense). "ux" comes from my usual design abbreviations where it means "User eXperience", which has also since become a popular acronym. I have found this to be extremely helpful in that I get the desired grouping in the intellisense even better than if I use "txt", "lbl" etc. It also allows you to change combo boxes to text boxes etc. without having to change the names - something that happens often during initial prototyping, or when programming using highly iterative agile/xp methodologies. Why: This convention avoids problems with changing control types (textboxes to drop-down lists, or simple text box to some uber textbox, or text box to date picker, for example), and groups the items together in intellisense. It is also much shorter than most Hungarian conventions, and definitely shorter and less type-dependent than appending the control type to the end of the variable name. I will use generic suffixes which allow me enough freedom to change them around. "ux" prefix uxUserID, uxHeader, uxPatientDateOfBirth, uxSubmit Standard Based Upon Microsoft .NET Library Standards Same naming conventions as public/private member variables or procedure variables of the same scope. If exposed publicly from a class, use PascalCase. If private to a function/sub, use camelCase.. Do not use SCREAMING_CAPS Why: This convention is consistent with the .NET Framework and is easy to read. A sizable section of the Framework Design Guidelines is dedicated to why they chose not to go the SCREAMING_CAPS route. Using SCREAMING_CAPS also exposes more of the implementation than is necessary. Why should a consumer need to know if you have an enum, or (perhaps because they are strings) a class exposing public constants? In the end, you often want to treat them the same way, and black-box the implementation. This convention satisfies that criteria. SomeClass.SomePublicConstant localConstant _privateClassScopedConstant * Public class-level variables are universally frowned upon. It is considered to be a much better practice to use property procedures (accessors and mutators) to provide read and/or write access to a private member variable. If you must expose a member variable to other classes using "Public", follow the property naming conventions, but don't complain if your guilty conscience keeps you up at night ;-). Please don't copy and paste these conventions on your own site. Feel free instead to link directly to this page. That way you get the ability to automatically get updates when I make them, as well as get that warm fuzzy you get by not copying someone else's work. Schools and accredited educational institutions can paste these conventions on their own sites if and only if they include a direct link to this page an an attribution for the source of the information from "Pete Brown's irritatedVowel.com". Thank you for respecting my wishes on this. You Can find the standards for publicly exposed classes/properties etc at MSDN . If you want to run a tool to validate your code for public standards and required practices, download FXCop or use the analysis tools in Visual Studio 2005+. NET Programming Standards and Naming Conventions
Common .NET Naming Conventions
Type Standard / Convention Example Namespaces AppliedIS.TimeCard.BusinessRules
IrritatedVowel.Controllers
PeteBrown.DotNetTraining.InheritanceDemoPeteBrown.DotNetTraining.XmlAssemblies
IrritatedVowel.Controllers.dllClasses and Structs
InstanceManager
XmlDocument
MainForm
DocumentForm
HeaderControl
CustomerListDataSet (typed dataset) Collection Classes WidgetCollection Delegate Classes WidgetCallbackDelegate Exception Classes InvalidTransactionException Attribute Classes WebServiceAttribute Interfaces IWidget Enumerations Functions and Subs Properties and Public * Member Variables Parameters Procedure-Level Variables Class-Level Private and Protected Variables Controls on Forms Constants
Links .NET Programming Links
Good Mailing Lists VISBAS-L http://peach.ease.lsoft.com/archives/visbas-l.html Developmentor .Net Lists http://discuss.develop.com/ Useful Search Sites CodeHound - Programmer's Search Engine http://www.CodeHound.com Google Newsgroup Search http://www.deja.com/ .NET and Other Resource Sites .NET articles and Links http://www.yoda.arachsys.com/csharp/ GotDotNet.com http://www.GotDotNet.com WindowsForms.Net http://www.windowsforms.net/Default.aspx Asp.Net http://www.asp.net/Default.aspx Microsoft Patterns and Practices http://www.microsoft.com/resources/practices C#.net http://www.csharp.net CodeProject C# Site http://www.codeproject.com/csharp/ .NET Spider http://www.dotnetspider.com IIS FAQs http://www.iisfaq.com/ UDDI Resources http://www.uddi.org/solutions.html Microsoft VS.Net Home http://msdn.microsoft.com/vstudio/ .Net Hosting http://www.brinkster.com OpenWave SDK (Phone Emulator) http://www.openwave.com/products/developer_products/ .NET Rocks Talk Show http://www.dotnetrocks.com/ A site with tons of connection strings (nice!) http://www.connectionstrings.com MSDN TV http://msdn.microsoft.com/msdntv/ Specific Articles of Interest Older Web Services vs. Remoting Performance Comparison http://msdn.microsoft.com/webservices/building/default.aspx?pull=/library/en-us/dnbda/html/bdadotnetarch14.asp Death of the Browser - Why you should use Windows Forms http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadvnet/html/vbnet10142001.asp Gang of Four (GoF) Patterns for .Net/C# http://www.dofactory.com/Patterns/Patterns.aspx Article on Creating HttpHandlers and HttpModules in .Net http://www.15seconds.com/issue/020417.htm Installation and Deployment .NET Framework Bootstrap Installer http://microsoft.com/downloads/details.aspx?FamilyId=66350891-D15B-446B-BD69-F7F849224A00&displaylang=en Windows Updater Application Block http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/updater.asp?frame=true How to Distribute Config Files to Smart Clients (Windows Forms Apps) via the Web http://www.ondotnet.com/pub/a/dotnet/2003/01/27/ztd.html Windows Forms Deployment Options http://www.windowsforms.net/Default.aspx?tabindex=3&tabid=40#Deployment Standards and Specifications C# ECMA Spec http://www.ecma-international.org/publications/standards/ECMA-334.HTM C# 2.0 Spec http://msdn.microsoft.com/vcsharp/team/language/default.aspx WSDL Spec http://www.w3.org/TR/wsdl For programming standards and naming conventions, see the link on the left menu. Whidbey (VS .NET 2005) Information MSDN Whidbey Site (VS .NET 2005) http://msdn.microsoft.com/vstudio/whidbey/default.aspx The Whidbey Chronicles - IDE Enhancements for C# Developers http://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20040219CSHARPDF/manifest.xml ASP.NET 2.0 http://www.asp.net/whidbey/ Examples and Components Terrarium (Better than Pong.Net!) ;-) http://www.gotdotnet.com/terrarium/whatis/ Google Web Service http://www.google.com/apis/ Microsoft Exception Handling Application Block http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/emab-rm.asp VS.Net Power Toys and other Stuff http://www.gotdotnet.com/team/ide/ Additional Tools, Test-Driven Development, and Interesting Stuff NUnit Unit Testing Framework http://www.nunit.org/ XML Acceleration Appliance (Good for Web Services) http://www.datapower.com/ .NET Managed Data Providers CoreLab MySQL Direct Managed Provider http://crlab.com/mysqlnet/ MySqlNet MySQL and Postgres Managed Provider http://sourceforge.net/projects/mysqlnet/ CoreLab Oracle Direct Managed Provider http://crlab.com/oranet/ Corelab Postgres Direct Managed Provider http://crlab.com/pgsqlnet/ Microsoft Oracle Managed Provider http://www.microsoft.com/downloads/details.aspx?FamilyId=4F55D429-17DC-45EA-BFB3-076D1C052524&displaylang=en Oracle ODP Managed Provider http://otn.oracle.com/tech/windows/odpnet/content.html .NET Ports to Other Platforms and Enhancements/Research/Languages Mono on Linux http://www.go-mono.com/ Microsoft Shared Source CLI - Rotor (Free BSD, OS X, Win XP) http://msdn.microsoft.com/net/sscli On the Death of Microsoft Shared Source CLI Community Site http://weblogs.cs.cornell.edu/AllThingsDistributed/archives/000525.html Old Generics Support in C# (SSCLI Gyro) http://research.microsoft.com/projects/clrgen/ Microsoft F# http://research.microsoft.com/projects/ilx/fsharp.aspx
jQuery showing or hiding effects
In this article I explain some simple effects showing or hiding some elements on the page using jQuery.
In jQuery the two function show() and hide() simply work this.
Let's take example for show and hide div tag.
For that first takes two link for Show and Hide and div with some text.
<a href="#" id="btnShow">Show</a>
<a href="#" id="btnHide">Hide</a>
<div>Hello Demo for showing & hiding div using jQuery.</div>
In jQuery put script for showing or hiding elements insode $(document).ready() function.
<script src="http://code.jquery.com/jquery-latest.js" ></script>
<script>
$(document).ready(function(){
$('#btnShow').click(function(){
$('div').show("fast"); });
$('#btnHide').click(function(){
$("div").hide(1000); });
});
</script>
In above code simply show/hide <div> tag when btnShow click it show <div> tag and when btnHide click it hide <div> tag.
In above code you can see dollar sign"$" is nothing but a shorthand notation for find method in JQuery.
How to use Selector?
If you want to select any element in the page then you can use dollar sign "$" to get that element.
- Element Selector : for selecting all matching tag or elements use $('tagname') like $('div').
- ID Selector : for selecting element with the given id attribute use $('#id') like $('#btnShow').so,(#) used for access the element with id.
- CSS selector: for find all element with a CSS class use $('.ClassName') select all element with ClassName CSS class..
In jQuery one more event toggle( ) which handle both events show() and hide().If they are shown, toggle makes them hidden (using the hide method). If they are hidden, toggle makes them shown (using the show method).
<a href="#" id="btnToggle">Toggle</a>
$('#btnToggle').click(function () {
$('div').toggle("slow"); });
In above all events show(speed),hide(speed),toggle(speed) use can specify speed for showing and hiding elements.Speed may be "slow","normal","fast" or the number of milliseconds to run the animation (e.g. 1000).
jQuery IntroductionjQuery is a new kind of JavaScript Library or FrameWork,created by John Resig in 2006.jQuery is most powerfull JavaScript Library. jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.jQuery is designed to change the way that you write JavaScript.
How to use jQuery? First download jQuery latest version (v.1.3.1) from jQuery.com and add javascript to your page.
<html> </head> In above code $(document).ready event is work same as window.onload method of javascript.And executed when entire page and resources have been loaded in the DOM.All the events which you want in jQuery must call inside the $(document).ready() function. So,The events in Jquery are bound to elements inside the $(document).ready() method.The elements get bound when document.ready is fired. Also,you can add as many $(document).ready events on your page as you like but they are executed in the order they are added. |
Find Nth highest record from tableIn interview you can faced question like to give solution(query) for find Nth highest Record/number/salary from given employee table. TO find out 3rd highest salary from table --Find 3rd highest salary SELECT TOP 1 salary FROM ( SELECT DISTINCT TOP 3 salary FROM tblSalary ORDER BY salary DESC) S ORDER BY salary General form to find to Nth highest salary from table --Find Nth highest salary SELECT TOP 1 salary FROM ( SELECT DISTINCT TOP N salary FROM tblSalary ORDER BY salary DESC) S ORDER BY salary There are many solution to solve to this but above solution is easiest. Take other possible solution, SELECT MIN(salary) FROM tblSalary WHERE salary IN (SELECT DISTINCT TOP 3 salary FROM tblSalary ORDER BY salary DESC) --or-- SELECT MIN(salary) FROM (SELECT DISTINCT TOP 3 salary FROM tblSalary ORDER BY salary DESC) S |
SQL Server String FunctionsString functions are mainly used to change the case of strings,concatenate strings,reverse strings,extract various part of strings and perform many other types of string manipulation. In SQL Server there is a Several built-in string functions to perform string manipulations.All below functions takes string input value and return a string or numeric value. ASCII : Returns the ASCII code value of a character(leftmost character of string).
UNICODE : UNICODE function works just like ASCII function,except returns Unicode standard integer value. UNICODE could be useful if you are working with international character sets.
LOWER : Convert character strings data into lowercase.
UPPER : Convert character strings data into Uppercase.
LEN : Returns the length of the character string.
REPLACE : Replaces all occurrences of the second string(string2) in the first string(string1) with a third string(string3).
LEFT : Returns left part of a string with the specified number of characters counting from left.LEFT function is used to retrieve portions of the string.
RIGHT : Returns right part of a string with the specified number of characters counting from right.RIGHT function is used to retrieve portions of the string.
LTRIM : Returns a string after removing leading blanks on Left side.(Remove left side space or blanks)
RTRIM : Returns a string after removing leading blanks on Right side.(Remove right side space or blanks)
REVERSE : Returns reverse of a input string.
REPLICATE : Repeats a input string for a specified number of times.
SPACE : Returns a string of repeated spaces.The SPACE function is an equivalent of using REPLICATE function to repeat spaces.
SUBSTRING : Returns part of a given string. SUBSTRING function retrieves a portion of the given string starting at the specified character(startindex) to the number of characters specified(length).
STUFF : Deletes a specified length of characters and inserts another set of characters at a specified starting point. STUFF function is useful to inserts a set of characters(string2) into a given string(string1) at a given position.
CHARINDEX : Returns the starting position of the specified string(string1) in a character string(string2).
PATINDEX : PATINDEX function works very similar to CHARINDEX function.PATINDEX function returns the starting position of the first occurrence of a pattern in a specified string, or zeros if the pttern is not found. Using PATINDEX function you can search pattern in given string using Wildcard characters(%).The % character must come before and after pattern.
|
SQL Server Date Time Format
In SQL Server used Cast or Convert function to Format Date Time value or column into a specific date format.Both function are used to convert datetime to varchar or string.
CAST function Syntax: CAST(expression as data_type)
Let's convert current date time to varchar
select cast(getdate() as varchar)
CONVERT function is used to change or convert the DateTime formats.By using convert function you can get only Date part or only Time part from the datetime.
CONVERT Function Syntax: CONVERT(data_type,expression,date Format style)
Let's take Sql Server DateTtime styles example:
Format | Query |
USA mm/dd/yy | select convert(varchar, getdate(), 1) |
ANSI yy.mm.dd | select convert(varchar, getdate(), 2) |
British/French dd/mm/yy | select convert(varchar, getdate(), 3) |
German dd.mm.yy | select convert(varchar, getdate(), 4) |
Italian dd-mm-yy | select convert(varchar, getdate(), 5) |
dd mon yy | select convert(varchar, getdate(), 6) |
Mon dd, yy | select convert(varchar, getdate(), 7) |
USA mm-dd-yy | select convert(varchar, getdate(), 10) |
JAPAN yy/mm/dd | select convert(varchar, getdate(), 11) |
ISO yymmdd | select convert(varchar, getdate(), 12) |
mon dd yyyy hh:miAM (or PM) | select convert(varchar, getdate(), 100) |
mm/dd/yyyy | select convert(varchar, getdate(), 101) |
yyyy.mm.dd | select convert(varchar, getdate(), 102) |
dd/mm/yyyy | select convert(varchar, getdate(), 103) |
dd.mm.yyyy | select convert(varchar, getdate(), 104) |
dd-mm-yyyy | select convert(varchar, getdate(), 105) |
dd mon yyyy | select convert(varchar, getdate(), 106) |
Mon dd, yyyy | select convert(varchar, getdate(), 107) |
hh:mm:ss | select convert(varchar, getdate(), 108) |
Default + milliseconds mon dd yyyy hh:mi:ss:mmmAM (or PM) | select convert(varchar, getdate(), 109) |
mm-dd-yyyy | select convert(varchar, getdate(), 110) |
yyyy/mm/dd | select convert(varchar, getdate(), 111) |
yyyymmdd | select convert(varchar, getdate(), 112) |
Europe default + milliseconds dd mon yyyy hh:mm:ss:mmm(24h) | select convert(varchar, getdate(), 113) or select convert(varchar, getdate(), 13) |
hh:mi:ss:mmm(24h) | select convert(varchar, getdate(), 114) |
SQL server Date Time Function
Date time functions allow manipulating columns with DATETIME/SMALLDATETIME data types. SQL server Date Time Function:
GETDATE and GETUTCDATE Functions
GETDATE and GETUTCDATE Functions are Nondeterministic function. Both functions returns the current date and time. GETDATE returns current system date and time of the computer where SQL Server is running.
GETUTCDATE returns current UTC time (Universal Time Coordinate or Greenwich Mean Time). The current UTC time is derived from the current local time and the time zone setting in the operating system of the computer on which the instance of Microsoft SQL Server is running.
DATEADD Functions
DATEADD function is Deterministic function. DATEADD Function adds a certain interval of time to the specified date and time value.
Syntax: DATEADD (datepart , number, date )
DATEADD returns a new date time value based on adding an interval to the specified date and time value.
DATEDIFF Function
DATEDIFF function is Deterministic function. DATEDIFF () gives the difference between the two date values.
Syntax: DATEDIFF ( datepart , startdate , enddate )
DATEDIFF returns number of date and time boundaries crossed between two specified dates. In DATEDIFF function start date is subtracted from end date. If start date is later than end date, a negative value is returned.
DATEPART Function
To retrieve any part of date and time use DATEPART function.
Syntax: DATEPART ( datepart , date )
DATEPART function takes two arguments 1)part of the date that you want to retrieve and 2)date itself. The DATEPART function returns an integer that represents date part of specified date.
DATEPART | Output |
SELECT DATEPART(year, '2009-02-13 18:35:06.523') | 2009 |
SELECT DATEPART(quarter, '2009-02-13 18:35:06.523') | 1 |
SELECT DATEPART(month, '2009-02-13 18:35:06.523') | 2 |
SELECT DATEPART(dayofyear, '2009-02-13 18:35:06.523') | 44 |
SELECT DATEPART(day, '2009-02-13 18:35:06.523') | 13 |
SELECT DATEPART(week, '2009-02-13 18:35:06.523') | 7 |
SELECT DATEPART(weekday, '2009-02-13 18:35:06.523') | 6 |
SELECT DATEPART(hour, '2009-02-13 18:35:06.523') | 18 |
SELECT DATEPART(minute, '2009-02-13 18:35:06.523') | 35 |
SELECT DATEPART(second, '2009-02-1 18:35:06.523') | 6 |
SELECT DATEPART(millisecond, '2009-02-1 18:35:06.523') | 523 |
DATENAME Function
DATENAME Function returns a character string that represents date part of the specified date.
Syntax: DATENAME ( datepart , date )
DATENAME function takes two arguments same as DATEPART function 1) part of the date that you want to retrieve and 2) date itself.
If you want the name of month
SELECT DATENAME (month, '2009-02-13 18:35:06.523') => Output : February
If you want the name of week day
SELECT DATENAME (weekday, '2009-02-13 18:35:06.523') => Output : Friday
DAY, MONTH, and YEAR Functions
All of this DAY, MONTH, and YEAR functions takes a single date value as a argument. Each of this function returns an integer that represents respective portions of the date.
SELECT DAY('2009-02-1 18:35:06.523') as 'Day', MONTH('2009-02-1 18:35:06.523') as 'Month', YEAR('2009-02-1 18:35:06.523') as 'Year'
Each of this functions equivalent to DATEPART function. Like DAY is equivalent to DATEPART (dd, date), MONTH is equivalent to DATEPART (mm, date) and YEAR is equivalent to DATEPART (yy, date).
SQL Server 2005 Query Analyzer shortcuts.
Some important shortcuts list for query execute.Using this shortcuts you can save lots of time.
- CTRL+E : Execute Query
- F5 : Execute Query
- ALT+BREAK : Cancel Query
- CTRL+D : Display results in grid format
- ALT+F1 : Database object info
- CTRL+F5 : Parse query and check syntax
- CTRL+K : Display/hide execution plan
- CTRL+L : Display execution plan
- CTRL+N : New Query window
- CTRL+SHIFT+F : Save results to file
- CTRL+Delete : Delete through the end of the line
.Net Shortcut Keys
A B C 1 2 Dotnet Shortcut Keys 3 4 S.No Shortcut Key Function 5 6 1 Ctrl + Shift + N Create New Project 7 2 Ctrl + N Create New File 8 3 Ctrl + Shift + O Open Project 9 4 Ctrl + O Open File 10 5 Ctrl + S Save File 11 6 Ctrl + Shift + S Save All File 12 7 Alt + F + X Close All 13 8 Ctrl + Z Undo 14 9 Ctrl + Y Redo 15 10 Ctrl + X Cut 16 11 Ctrl + C Copy 17 12 Ctrl + V Paste 18 13 Ctrl + A Select All 19 14 Ctrl + F Quick Find 20 15 Ctrl + H Quick Replace 21 16 Ctrl + Shift + F Find in Files 22 17 Ctrl + Shift + H Replace in Files 23 18 Alt + F12 Find Symbol 24 19 Ctrl + G Go To Line No. 25 20 Ctrl + P Print 26 21 Ctrl + K, Ctrl + D Format Document 27 22 Ctrl + K, Ctrl + F Format Selection 28 23 Ctrl + Shift + U Make Upper Case 29 24 Ctrl + U Make Lower Case 30 25 Ctrl + K, Ctrl + \ Delete Horizontal White Space 31 26 Ctrl + R, Ctrl + W View White Space 32 27 Ctrl + E, Ctrl + W Word Wrap 33 28 Ctrl + I Incremental Search 34 29 Ctrl + K, Ctrl + C Comment Selection 35 30 Ctrl + K, Ctrl + U Uncomment Selection 36 31 Ctrl + K, Ctrl + K Toggel Book Mark 37 32 Ctrl + K, Ctrl + P Previous Book Mark 38 33 Ctrl + K, Ctrl + N New Book Mark 39 34 Ctrl + K, Ctrl + L Clear Book Marks 40 35 Ctrl + Shift + K, Ctrl + Shift + P Previous Book Mark in Folder 41 36 Ctrl + Shift + K, Ctrl + Shift + N Next Book Mark in Folder 42 37 Ctrl + K, Ctrl + H Remove Task List Shortcut 43 38 Ctrl + M, Ctrl + M Toggel Out Lining Expansion 44 39 Ctrl + M, Ctrl + L Toggel All Out Lining 45 40 Ctrl + M, Ctrl + P Stop Out Lining 46 41 Ctrl + M, Ctrl + O Collapse to Definitions 47 42 Ctrl + K, Ctrl + M Generate Method Stub 48 43 Ctrl + J List Members 49 44 Ctrl + Shift + Space Parameter Info 50 45 Ctrl + K, Ctrl + I Quick Info 51 46 Alt + Right Arrow Complete Word 52 47 Ctrl + K, Ctrl + X Insert Snippet 53 48 Ctrl + K, Ctrl + S Surround With 54 49 Ctrl + Alt + S Open Server Explorer 55 50 Ctrl + Alt + L Open Solution Explorer 56 51 Ctrl + K, Ctrl + W Bookmark Window 57 52 Ctrl + Shift + C Class View 58 53 Ctrl + \ , Ctrl + D Code Definition Window 59 54 Ctrl + Alt + J Object Browser 60 55 Ctrl + \ , Ctrl + E Error List 61 56 Ctrl + Alt + O Output 62 57 F4 Properties window 63 58 Ctrl + \ , Ctrl + T Task List 64 59 Ctrl + Alt + X Tool Box 65 60 Ctrl + Alt + A Command Window 66 61 Ctrl + Alt + T Document Outline 67 62 Ctrl + Shift + E Resource View 68 63 Alt + F8 Macro Explorer 69 64 Ctrl + Alt + R Web Browser 70 65 Shift + Alt + Enter Full Screen 71 66 Ctrl + Shift + A Add New Item 72 67 Shift + Alt + A Add Existing Item 73 68 Ctrl + Shift + B Build Solution 74 69 Ctrl + Alt + B Break Points 75 70 F5 Start Debugging 76 71 Ctrl + F5 Start without Debugging 77 72 F10 Step Over 78 73 F11 Step In 79 74 F9 Toggel Breakpoint 80 75 Ctrl + Shift + F9 Delete All Break points 81 76 Ctrl + F1 How Do I Help 82 77 Ctlr + Alt + F3 Search 83 78 Ctrl + Alt + F1 Contents 84 79 Ctrl + Alt + F2 Index 85 80 Ctrl + Page Up View Designer 86 81 Ctrl + Page Down View Source 87