Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

NZ function in SQL Server

17.05.2018 (👁10551)


 

Under Microsoft SQL Server, the Microsoft Access function NZ ([field], value-at-zero) can not be used.

Instead, you can use the ISNULL ([field], value-at-zero) function

 

As a Transact SQL command

UPDATE [dbo].[tbl_Notes]

 SET [sumViews] = ISNULL([sumViews],0)+1

 WHERE IDNote=8

 

Example:

The integer value SumViews was initially created with NULL, dbnull.

An Increase update with a SQL number increase would result in an error or result in NULL.

 

Test: Under SQL Server Management Studio, Query

 

Therefore the use of ISNULL (sumViews, 0) can be increased with +1 without problems.

If you let the script through once

 

Result:

the zero was increased as 0 + 1 directly on the SQL Server

with UPDATE [dbo]. [tbl_Notes]

  SET [sumViews] = ISNULL ([sumViews], 0) +1

 

Transact Script:

USE [readdy]

GO

 

UPDATE [dbo].[tbl_Notes]

 SET [sumViews] = ISNULL([sumViews],0)+1

 WHERE IDNote=8

GO