Saturday, August 10, 2013

Convert query from MS SQL Server to MS SQL Server Compact Edition 3.5

Issue 1: Data Type
In MS SQL Server, when creating a datatable, user can specify data type [char], [smalldatetime] and [varchar] as shown in the example below:

CREATE TABLE [product](
 [PRODUCTID] [int] NULL,
 [PRODUCTNAME] [varchar](50) NULL,
 [PRODUCTGROUPCODE] [varchar](50) NULL,
 [PRODUCTGROUPNAME] [varchar](50) NULL,
 [INSTOCKFLAG] [char](50) NULL,       
 [FULLPRICE] [money] NULL
) 

However, when port the above query to MS SQL Server Compact, the data types [char] and [varchar] must be changed to [nchar] and [nvarchar] (i.e. unicode-based [char] and [varchar], and the [smalldatetime] must be changed to [datetime] as shown in the example below:

CREATE TABLE [product](
 [PRODUCTID] [int] NULL,
 [PRODUCTNAME] [nvarchar](50) NULL,
 [PRODUCTGROUPCODE] [nvarchar](50) NULL,
 [PRODUCTGROUPNAME] [nvarchar](50) NULL,
 [INSTOCKFLAG] [nchar](50) NULL,
 [FULLPRICE] [money] NULL
) 

Issue 2:

No comments:

Post a Comment