Compatibility of bit type between SqlServer 2000 and SqlServer 2005

March 15, 2010 at 6:14 am Leave a comment

Recently, i have faced issue of compatibility of bit type between sqlserver 2000 and sqlserver 2005, while we were developing using SqlServer 2005 (express) and

the hosting company uses SqlServer 2000 and as soon as we deploy, we got the following

exception on one of the operations:

“Syntax error converting the varchar value ‘true’ to a column of data type bit”

I have resolved the problem without changing dbtype in our existing DB. If you are using

storeproce for inserting data in table then may be this solution helpful for you.

For this problem, we have changed all parameter type bit to varchar(@IsPermenant

[varchar](10)). After that cast with bit type when passing values in

storeprocedure(CAST(@IsPermenant as bit)).

Same as shown in below line.

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
Create PROCEDURE [dbo].[EmployeeInsert]
@FirstName [varchar](30),
@MiddleName [varchar](30),
@State [int],
@IsPermenant [varchar](10)
AS
Begin

INSERT INTO EmployeeInsert
(FirstName
,MiddleName

,State
,IsPermenant)
VALUES
(@FirstName,

@MiddleName,
@LastName,
CAST(@IsPermenant as bit))
Set

@ID=SCOPE_IDENTITY()
END

This above solution succefully running on our prodiction site. With this solution we

can resolve our problem without changing dbtype in our existing table.

Happy Programming :-)

Entry filed under: Uncategorized. Tags: .

Sample Sql server queris like print two concate value using cursor & How do I get the 2nd row in a SQL Server table

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Blog Stats

  • 1,351 hits

Top Clicks

  • None

Follow

Get every new post delivered to your Inbox.