mssql if not exists insert else update

//update user table
string strSQL = " IF NOT EXISTS (select * from users where uid = @uid) \n\r" +
" BEGIN \n\r" +
"  INSERT INTO users (nickname) values (@nickname) \n\r" +
" END \n\r " +
" ELSE \n\r " +
" BEGIN \n\r" +
"  UPDATE users set nickname=@nickname where uid=@uid \n\r" +
" END";
myCommand = new SqlCommand(strSQL,conn);
myCommand.Parameters.Add("@uid", SqlDbType.VarChar, 50).Value = uid;
myCommand.Parameters.Add("@nickname", SqlDbType.NVarChar,50).Value = nickname;
myCommand.ExecuteNonQuery();