Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/101847

From BetaArchive Wiki

PRB: Host_name() Function Returns NULL Value


The information in this article applies to:

  • Microsoft SQL Server version 4.2x


After upgrading from version 1.x to 4.2, an application or stored procedure that uses the system function host_name() to insert a value into a row generates the following error message (error 515):

Attempt to insert the value NULL into column '%.*s', table '%.*s';
column does not allow nulls. Update fails.


The system function host_name() has changed behavior between version 1.x and 4.2. The host_name() function is supposed to return the value that was set by the front-end application by calling DBSETLHOST. If this was not set by the application, the return value depends on the version of the SQL Server; version 1.x returns a string of 30 spaces, and version 4.2 returns a NULL value.


There are several ways to address this situation. The application could be changed to call DBSETLHOST to provide a value. Secondly, the column that is used to store the host_name could be changed to allow NULLs, or, in the case of a stored procedure, the ISNULL function could be used to provide a value when host_name returns NULL.

Additional query words: DB-Lib DB-Library dblib 4.2 4.2a

Keywords : kbother
Issue type :
Technology : kbSQLServSearch kbAudDeveloper kbSQLServ420OS2

Last Reviewed: March 18, 1999
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.