16
declare @inserted bit
declare @removed bit

I know it's possible to set them like below:

SELECT @inserted = 0, @removed = 0

but would it be possible to make this even simpler and use something like:

SET @inserted, @removed = 0

Many thanks

2 Answers 2

27

How about:

declare @inserted BIT = 0, @removed BIT = 0

Works in SQL Server 2008 and up (you didn't specify which version of SQL Server....)

Update: ok, so you're stuck on SQL Server 2005 - in that case, I believe this is the best you can do:

DECLARE @inserted BIT, @removed BIT
SELECT @inserted = 0, @removed = 0
Sign up to request clarification or add additional context in comments.

Comments

1

but would it be possible to make this even simpler and use something like:

SET @inserted, @removed = 0

I suppose yo mean

SET @inserted = @removed = 0

No, that is not possible. T-SQL does not support this kind of syntax.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.