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: .
Trackback this post | Subscribe to the comments via RSS Feed