I have table like
Col1, Col2, Col3, Col4
---- ---- ----
1 0 1 sd
1 0 2 asdas
1 1 1 sd
1 1 2 ads
2 0 1 sad
2 0 2 ds
2 1 1 sad
2 1 2 sad
This table represent all possibilities that I have.I need to update or insert row. If one row in above table does not exist I will insert new row. If I send -1 for Col1 or Col2 or Col3, I need to update/insert all variants of that column.
Col1 accept 1 and 2.
Col2 accept 0 and 1.
Col3 accept 1 and 2.
For example:
Col1 = -1, Col2 = 1, Col3 = -1, Col4 = test
I need to update/insert next columns
Col1, Col2, Col3, Col4
---- ---- ----
1 1 1 test
1 1 2 test
2 1 1 test
2 1 2 test
Can you help me with stored procedure?
CREATE PROCEDURE [dbo].[MyStoredProcedure]
(
@Col1 int,
@Col2 int,
@Col3 int,
@Col4 uniqueidentifier
)