passing Nulls to SQL Server 2005
I have some stored procedures in a SQL Server 2005 database to which I pass
Excel data by way of VBA. These sprocs have parameters, some of which are expecting strings from cells in text-type columns in Excel - these are then passed to database fields of type varchar or nvarchar. This code currently falls over if one of these cells has nothing in it. Does anyone know of a way in Excel/VBA that I can pass nulls successfully to text fields in SQL Server? Perhaps some VBA constant I haven't heard of. (I know I can deal with it in the stored procedures by setting defaults of null and then using If conditions but this seems unnecessarily overcomplicated.) |
passing Nulls to SQL Server 2005
Maybe try passing a nullstring (""), or maybe use the Null keyword.
-- Hope that helps. Vergel Adriano "Smallweed" wrote: I have some stored procedures in a SQL Server 2005 database to which I pass Excel data by way of VBA. These sprocs have parameters, some of which are expecting strings from cells in text-type columns in Excel - these are then passed to database fields of type varchar or nvarchar. This code currently falls over if one of these cells has nothing in it. Does anyone know of a way in Excel/VBA that I can pass nulls successfully to text fields in SQL Server? Perhaps some VBA constant I haven't heard of. (I know I can deal with it in the stored procedures by setting defaults of null and then using If conditions but this seems unnecessarily overcomplicated.) |
passing Nulls to SQL Server 2005
Thanks Vergel but those don't seem to work. I'm currently working around it
by passing a space " " for empty cells but it seems a bit clumsy! "Vergel Adriano" wrote: Maybe try passing a nullstring (""), or maybe use the Null keyword. -- Hope that helps. Vergel Adriano "Smallweed" wrote: I have some stored procedures in a SQL Server 2005 database to which I pass Excel data by way of VBA. These sprocs have parameters, some of which are expecting strings from cells in text-type columns in Excel - these are then passed to database fields of type varchar or nvarchar. This code currently falls over if one of these cells has nothing in it. Does anyone know of a way in Excel/VBA that I can pass nulls successfully to text fields in SQL Server? Perhaps some VBA constant I haven't heard of. (I know I can deal with it in the stored procedures by setting defaults of null and then using If conditions but this seems unnecessarily overcomplicated.) |
All times are GMT +1. The time now is 10:07 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com