BUG: ROUND Function with NULL Length Returns TDS ErrorID: Q199105
|
The Transact-SQL ROUND function may return a Tabular Data Stream (TDS) error if the second argument (length) is passed in as NULL.
To avoid the problem, check the second argument before passing it in to the ROUND function. If it is NULL, simply return NULL and do not use the ROUND function at all. You can use the ISNULL function to accomplish this.
Microsoft has confirmed this to be a problem in SQL Server version 7.0.
The syntax for the ROUND function is:
ROUND(numeric_expression, length [,function])
-or-DB-Library: Possible network error: Bad token from SQL Server: Datastream processing out of sync.
Net-Library error 0: (null)
DB-Library: DBPROCESS is dead or not enabled.
For example, following query demonstrates this behavior:[Microsoft][ODBC SQL Server Driver]Unknown token received from SQL Server.
Create table testtable (col1 int not null, col2 int null)
go
insert into testtable values(1,NULL)
go
select ROUND(col1,col2)from testtable
go
declare @param int
select @param = NULL
select ROUND(1,@param)
go
select ROUND(1,(select NULL))
go
select ROUND(1,NULL)
This is true for sp_dbcmptlevel 65 as well.Argument data type void type is invalid for argument 2 of round function.
Additional query words: err msg
Keywords : SSrvTran_SQL kbbug7.00
Version : winnt:7.0
Platform : winnt
Issue type : kbbug
Last Reviewed: February 5, 1999