sql server - How can I get the MAX value of a column from a record or 0 if no record is matched in my SELECT? -



sql server - How can I get the MAX value of a column from a record or 0 if no record is matched in my SELECT? -

i have stored procedure utilize insert. when inserting record value of release equal 1 more highest value. here coded:

declare @maxrelease int; select @maxrelease = max(release) dbo.test testtypeid = @testtypeid , examid = @examid , title = @title; insert ... @maxrelease + 1 ... etc.

however how can create if there nil returned select (because there no current records) value of @maxrelease 0?

you can utilize isnull (transact-sql) replace null value replacement value.

select @maxrelease = isnull(max(release), 0) dbo.test

sql-server

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -