2

Is it possible to update this view by specifying the MessageTech and the txtmessageID? (txtmessageID and MessageId are the primary keys from the respective base tables.)

(SELECT
 txtmessageID,
 'S' AS MessageTech,
 MessageType,
 Message,
 MessageDate,
 MessageMobile,
 MessageRead,
 MessageSender
FROM
 MessageCentre)
UNION ALL
(SELECT
 MessageId,
 'E' AS MessageTech,
 Type,
 Text,
 Date,
 Address,
 [Read],
 Sender
FROM
 MessageCentreEmail)
asked Nov 6, 2016 at 20:41
0

1 Answer 1

3

The with some modification the view should be updateable, but not in its current form. https://msdn.microsoft.com/en-au/library/ms187956.aspx gives the rules for Partitioned Views

Some things you would need to change:

  1. MessageTech column would need to be part of the underlying tables
  2. MessageTech needs to be part of the primary key of each underlying table
  3. MessageTech needs to have constraints on it in each table such that a given value could not possibly refer to more than one table e.g.

ALTER TABLE MessageCentre Add 
 MessageTech char(1) Not Null Default 'S',
 Constraint chk_MessageTechIs_S Check (MessageTech = 'S');

There are some other conditions too, which you can read about in that link, but those are the obvious changes that would need to occur.

answered Nov 7, 2016 at 0:54
1

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.