Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updatable View

Status
Not open for further replies.

GGraff

Programmer
May 11, 1999
1
0
0
IT
Hi, I have created a view as follows:
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


ALTER View v_LoadGrid WITH VIEW_METADATA as

SELECT ORG_tblOrganizations.ORG_strOrganizationLegalName AS Company, ORG_trelOrganizationLocations.ORG_strLocationStateCode AS State,
ORG_tlkpOrganizationRoles.ORG_idsRoleID_PK, PEO_tblPeople.PEO_strFirstName + ' ' +
PEO_tblPeople.PEO_strLastName As Dispatcher, '(' + PHO_tblPhoneNumbers.PHO_strAreaCode + ')' + ' ' +
PHO_tblPhoneNumbers.PHO_strExchange + ' - ' + PHO_tblPhoneNumbers.PHO_strNumber As Phone, '(' + PHO_tblPhoneNumbers.PHO_strAreaCode_Fax +
PHO_tblPhoneNumbers.PHO_strExchange_Fax + ' - ' + PHO_tblPhoneNumbers.PHO_strNumber_Fax As Fax, GEN_tblEmailAddresses.GEN_strEmailAddress As Email
FROM ORG_tlkpOrganizationRoles INNER JOIN
PEO_tblPeople ON ORG_tlkpOrganizationRoles.ORG_intPersonFillingRoleRef_FK = PEO_tblPeople.PEO_idsPeopleID_PK INNER JOIN
ORG_trelRoleToEmailAddress ON ORG_tlkpOrganizationRoles.ORG_idsRoleID_PK = ORG_trelRoleToEmailAddress.ORG_intRoleRef_FK INNER JOIN
ORG_trelOrgToPhones ON ORG_tlkpOrganizationRoles.ORG_idsRoleID_PK = ORG_trelOrgToPhones.ORG_intRoleRef_FK INNER JOIN
PHO_tblPhoneNumbers ON ORG_trelOrgToPhones.ORG_intPhoneNumberRef_FK = PHO_tblPhoneNumbers.PHO_idsPhoneNumberID_PK INNER JOIN
GEN_tblEmailAddresses ON
ORG_trelRoleToEmailAddress.ORG_intEmailAddressRef_FK = GEN_tblEmailAddresses.GEN_idsEmailAddressID_PK INNER JOIN
GEN_tblEmailAddresses GEN_tblEmailAddresses_1 ON
ORG_trelRoleToEmailAddress.ORG_intEmailAddressRef_FK = GEN_tblEmailAddresses_1.GEN_idsEmailAddressID_PK RIGHT OUTER JOIN
ORG_trelOrganizationLocations ON
ORG_tlkpOrganizationRoles.ORG_intPrimaryLocationRef_FK = ORG_trelOrganizationLocations.ORG_idsLocationID_PK LEFT OUTER JOIN
ORG_tblOrganizations ON ORG_trelOrganizationLocations.ORG_intOrganizationRef_FK = ORG_tblOrganizations.ORG_idsOrganizationID_PK


GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO

How do i create a trigger to update this viw, am lost
 
triggers are created on tables what you might actually need is a stored procedure which will allow you to update data in tables

What are you trying to update?

Andy
 
You can create INSTEAD OF triggers on views. The INSTEAD OF code fires in place of the standard action. Check out Designing INSTEAD OF Triggers in BOL.

It looks like you have some complex coding to do. The example in BOL is based on a two-table view; yours has nine tables. Good luck!

--Angel [rainbow]
-----------------------------------
Every time I lose my mind, I wonder
if it's really worth finding.
 
Updating views can be tricky especially if you don't use an instead of trigger. YOu might want to read this topic in books online:
views-SQL Server, modifying data

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top