True False Access SQL Server

Problema tipico:

"I'm upgrading an application that uses a VBScript/ASP front-end and MS Access Backend. The application has many points expecting fields to be true or false..E.g. SELECT * FROM MyTable WHERE Active=TrueHowever, since SQL Server requires 0 or 1 for bit fields, this query keeps failing. SQL Server (2005 Express) thinks True is a column name and is not automatically converting "True" to 1.
is there a way to make SQL server do this conversion automatically?"

Solucion:

SELECT CONVERT (bit, 'true'), CONVERT(bit, 'false')

Explicacion de Microsoft: http://msdn2.microsoft.com/en-us/library/ms191240.aspx

Ademas, recordar que True en Access es -1 y en SQL Server es 1

Comentarios

Entradas populares de este blog

Ejecutar programa o servicio al iniciar windows server

Crear una maquina virtual Vmware desde una imagen Ghost de una maquina real

Problema para aceptar los terminos de la licencia de Adobe Acrobat - No funcionan los botones