.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Convert NVARCHAR column data into DATETIME - SQL Server 2000

Posted By:      Posted Date: October 19, 2010    Points: 0   Category :Sql Server

ExpiryDate column in Table Data Type is NVARCHAR , storing Dates ONLY without time as 2/10/2010 , 12/10/2010 IN DD/MM/YYYY FORMAT.



SUM(CASE WHEN CONVERT(datetime,a.expirydate,103) >= (CONVERT(datetime,'2010-01-07',103)) AND 
		CONVERT(DATETIME,a.ExpiryDate,103) < dateadd(month,1,(convert(datetime,'2010-01-09', 103))) THEN 1 ELSE 0 END) AS Expired


Your help is greatly appreciated. Spent hours to get this resolved.


View Complete Post

More Related Resource Links

Convert NVARCHAR column to DateTime - SQL Server


Hi there,

Have spent few hours to get this working. I like to get help now. Please note MONTH AND DATES stored in single or double digits as they occur.

Unfortunately DATE TIME is stored in NVARCHAR Data type column as 2/9/2010,  22/10/2010 etc. Following UK Date here.

It is required to pull the data to COUNT No. of Expired. Obviously below one fails.

--AS Date AND Month stored in Single digits AND double digits , below statement 
--thorws Arthmetic overflow exception
SUM(CASE WHEN CONVERT(DATETIME,ExpiryDate,103) >= (CONVERT(datetime,'2010-01-07',103)) AND    
 CONVERT(DATETIME,ExpiryDate,103) < dateadd(month,1,(convert(datetime,'2010-01-09', 103))) THEN 1 ELSE 0 END) AS Expired  


Convert NVarchar to DateTime - SQL Server 2000


Hi there,


Using SQL Server 2000.

ALTER PROCEDURE [dbo].[CountUsers]
			@startMonth nvarchar(20) =	NULL,
			@startYear nvarchar(20) = NULL,
			@endMonth  nvarchar(20) = NULL,
			@endYear  nvarchar(20) = NULL,
			@startDate nvarchar(50) = NULL,
			@endDate  nvarchar(50) = NULL

		SET @startDate = @startYear + '-01-' + @startMonth; 
		SET @endDate  = @endYear + '-01-' + 

Data Points: XML Features in SQL Server 2000


SQL ServerT 2000 includes several XML features that let you transform relational rowsets into hierarchical XML documents, read XML documents, and bulk load data via XML. For example, you can pass an XML document to a stored procedure, join the XML to some tables and return a rowset, or even modify data in the database.

John Papa

MSDN Magazine June 2005

Metadata: Create a Database Schema Repository with Meta Data Services in SQL Server 2000


SQL Server 2000 Meta Data Services is a repository technology that stores and manages metadata for SQL Server. Instead of building database schemas over and over, Meta Data Services allows you to freeze an entire schema for use in other projects. You can also use these schemas for training, testing, or debugging. In this article, the authors will review the various components of Meta Data Services and show how it can be programmed using a Visual Basic client, XML, and XSLT. They will also show you how to manage and manipulate your metadata by generating a simple database schema using a SQL Server repository.

Alok Mehta and Ricardo Rodriguez

MSDN Magazine May 2003

Scripting SQL: VBScript Interfaces in SQL Server 2000 Let You Transform Data and Provide Reports to


Application service providers often must send information to clients automatically rather than on-demand. For example, a manufacturer may want to know each day how many of their products were sold by a retail chain. While SQL Server is ideal for maintaining this type of database, you have to write scripts to get the data out in a client-friendly format. Here you will see how you can use Data Transformation Services (DTS), a powerful tool in SQL Server, to automate the retrieval and formatting of data from SQL Server 2000 and make the process of pushing data to your users a lot easier.

Alok Mehta and Daniel Williams

MSDN Magazine August 2002

SQLXML 3.0: Build Data-Driven Web Services with Updated XML Support for SQL Server 2000


XML is becoming the ubiquitous data format on the Web, and XML support in SQL Server is evolving to meet the additional demand. Using XML, SOAP, HTTP, and SQL Server, you can now build powerful Web Services easily. To show just how simple it is with SQLXML 3.0, this article walks the reader through the process step by step, from setting up a virtual directory enabling data access via HTTP to executing queries and building Web Services. Finally, the author illustrates the creation of two Web Services clients-one with C# that works with the Microsoft .NET Framework and one with the SOAP Toolkit 2.0 for anyone still using earlier development tools.

Christian Thilmany

MSDN Magazine May 2002

SQL Server 2000 and XML: Developing XML-Enabled Data Solutions for the Web


Using XML for data access allows you to separate the data from the presentation, and promotes reuse, extensibility, and division of labor. XML also has a simplified data model, which promotes easier testing. This article presents and compares five data access approaches, using a variety of technologies including ASP and ADO, XSLT, and DirectXML. Once built, the solutions are compared on the basis of their speed and efficiency.

Scott Howlett and Darryl Jennings

MSDN Magazine January 2002

ssis sql 2000 image to 2008 varbinary Failed to retrieve long data for column

Hi, I have a task that to migrate the image type column from sql 2000 to varbinary type in sql 2008. The source column having 3812353 max datalength size for the column. The package always failed with following error message. [OLE DB Source [13177]] Error: Failed to retrieve long data for column "attch_file_content_t". [OLE DB Source [13177]] Error: There was an error with output column "attch_file_content_t" (13209) on output "OLE DB Source Output" (13187). The column status returned was: "DBSTATUS_UNAVAILABLE". [OLE DB Source [13177]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "output column "attch_file_content_t" (13209)" failed because error code 0xC0209071 occurred, and the error row disposition on "output column "attch_file_content_t" (13209)" specifies failure on error. An error occurred on the specified object of the specified component. There may be error messages posted before this with more information about the failure. Meng Chew

data migrations from sql server 2000 to 2008

Hi,   Can any one please help me by giving some good links / tutorials  for migrating data from sql server 2000 to 2008 using SSIS     Thanks In Advance    Padmaja 


Hi Friends, I am creating an application for a jewellery shop (MINOR PROJECT) in VB.Net but my problem is that I dont know how to insert multiple records for same bill number. consider the following condition Bill Number Customer Name   ............................................... Customer Address ................................................ S.No                 Item name                Rate    Qty                            Total 1                      abc                            5        5                                 25 2                 &nb

what is stored the guidlocal column in MSmerge_genhistory table (MS SQL Server 2000)?

In MSmerge_genhistory table there is a column called guidlocal. I noticed that for a large subset of the records on both the publisher and the subscriber, the value in this column is '00000000-0000-0000-0000-000000000000'. What does it mean? BOL says that guidlocal is: "Local identifier of the changes identified by generation at the Subscriber." but I still can't make it out what does '00000000-0000-0000-0000-000000000000' mean?

Importing Data from Excel into SQL Server using SSIS: some datetime values appear as NULLS How to Re

I created a Package in the Business Intelligence studio to Import data from Excel file  into SQL Server 2005 using a Excel Source and a OLE DB Destination that uses a data convertion transformation before it reaches the destination a mjority of the data is copied over. However i am having 2 Issues. 1. In the Date field some of the values appear as Null in SQL Server 2. I need to change the format of the date in Excel from dd/mm/yyyy to mm/dd/yyyy before inserting into SQL Server if Possible. I am not sure of the solution for Ques 1 but i attempted using a script task for #2 It did not work. Please Advice what the best way to proceed Thanks.

Error converting data type nvarchar to datetime.

hi all, I simply explain my application.plz try to understand. In my applicationi want to generate one complaint id.one customer may give two or more complaints at a time.suppose,he give two or more pnr numbers and their status and prioirty may differs.for this complaint i need to generate one common complaint id.how it is possible..?with some constant rows. am getting error in Class File near CLUser_Logged_DTClass File using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Data.SqlClient; using System.Web.Configuration; /// <summary> /// Summary description for BalComplaints /// </summary> public class BalComplaints { public BalComplaints() { // // TODO: Add constructor logic here // } int SNo, Complaint_Type_ID, Caller_Type_ID, No_of_Articles, Article_ID, CLPriority_ID, Status_ID, Origin_ID, Destination_ID; public int SNo1 { get { return SNo; } set { SNo = value; } } public int Caller_Type_ID1 { get { return Caller_Type_ID; } set { Caller_Type_ID = value; } } public int Destination_ID1 { get { return Destination_ID; } set { Destination

Data Import sql server 2008 to SQL 2000


HI All,

How to Import data from sql server 2008 to sql server 2000 ? (i don't have any idea about SSIS, expect this any chance is there? i was try with import functionality some records are copy after it was faild i have nearly 80 Lacks records)

Please help me how to solve this issue this is very urgent form me...

Thanks, Prasad.

Convert excel rows wise data into column wise


public static string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;";

               OleDbDataAdapter adapter = new OleDbDataAdapter();

            OleDbCommand selectCommand = new OleDbCommand("SELECT * FROM [Sheet1$]");

            OleDbConnection connection = new OleDbConnection(connectionString);

            selectCommand.Connection = connection;

            adapter.SelectCommand = selectCommand;

            DataSet cities = new DataSet();


Convert Text to Numeric in reports generated by Microsoft SQL Server 2000

Our programming team is producing Excel reports using Microsoft SQL Server 2000 and cannot seem to find a way to produce numeric data as numeric.  It is being produced in the spread sheet as text (with the green triangle in the corner of the cell).  If the user viewing the report has an older version of Excel they cannot even convert it to numeric manually. 

Is there a way to produce numeric data as numeric in the Excel report?

SQL Server DateTime Convert pattern


I need the datetime to be in the following format for SQL server 2005

dd/MM/YYYY HH:MI in 24 Hour Format

note: seconds are not included


Thanks for any help in advance

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend