How about this?
select DATEPART(MM,'january 01 2011') -- returns 1
select DATEPART(MM,'march 01 2011') -- returns 3
select DATEPART(MM,'august 01 2011') -- returns 8
More Related Contents:
- About SQL Server IF clause [closed]
- SQL Server, How to set auto increment after creating a table without data loss?
- When should I use a table variable vs temporary table in sql server?
- How can I determine installed SQL Server instances and their versions?
- Datatype for storing ip address in SQL Server
- Add IIS 7 AppPool Identities as SQL Server Logons
- SQL Server: Query fast, but slow from procedure
- Errors: “INSERT EXEC statement cannot be nested.” and “Cannot use the ROLLBACK statement within an INSERT-EXEC statement.” How to solve this?
- Is there a way to loop through a table variable in TSQL without using a cursor?
- sql server invalid object name – but tables are listed in SSMS tables list
- How to get a date in YYYY-MM-DD format from a TSQL datetime field?
- How do I format a number with commas in T-SQL?
- What columns generally make good indexes?
- What is a free tool to compare two SQL Server Databases? [closed]
- SQL Server Management Studio alternatives to browse/edit tables and run queries [closed]
- SQL Server: Database stuck in “Restoring” state
- SQL server schema and default schema
- SQL Server ON DELETE Trigger
- SQL to find first non-numeric character in a string
- How to decrypt a password from SQL server?
- FOR XML PATH(”): Escaping “special” characters
- Unable to login to SQL Server + SQL Server Authentication + Error: 18456
- Convert a string with ‘YYYYMMDDHHMMSS’ format to datetime
- What are the advantages of VistaDB
- How to pivot unknown number of columns & no aggregate in SQL Server?
- Create Stored Procedures using Entity Framework Code First?
- “If not exists” fails on SQL CE
- Incorrect syntax near ‘)’ calling stored procedure with GETDATE
- Generate MD5 hash string with T-SQL
- Why can’t Entity Framework see my Stored Procedure’s column information?