Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6590949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:21:49+00:00 2026-05-25T17:21:49+00:00

I have the following schema: [dbo].[tbl_Events] [Event_ID] [uniqueidentifier] NOT NULL (PK) [Location_ID] [uniqueidentifier] NULL

  • 0

I have the following schema:

[dbo].[tbl_Events]

[Event_ID] [uniqueidentifier] NOT NULL (PK)
[Location_ID] [uniqueidentifier] NULL (FK)
[Observation] [nvarchar]

[dbo].[tbl_Locations]

[Event_ID] [uniqueidentifier] NOT NULL
[Location_ID] [uniqueidentifier] NULL (PK)
[Notes] [nvarchar]

Locations is the parent table with a relationship to events through Location ID.

Location_ID is set to be NewID() on create in Locations, and Event_ID is set to be NewID() on create in events. The table, relationship, and PK format is non-changeable due to organizational policy governing replication.

I’m looking for advice on how to define an insert trigger that will create a new row in events, with the location_id pulled from the parent location table, and a new unique event_id. E.g., when (by outside application with no ability to embed sql code) a new location record is created, it gets a location_id of 8170daed-92c8-47f1-98ca-147800329686, and the trigger creates a new event record also with a location_ID of 8170daed-92c8-47f1-98ca-147800329686 and an event_ID of cfed8fe8-b5be-4f78-b366-008672e39637.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:21:50+00:00Added an answer on May 25, 2026 at 5:21 pm

    I’m going to assume that your dbo.tbl_Locations schema definition is just typo’d and Location_ID is NOT NULL while Event_ID is NULL (since Location_ID is the PK and auto-generated).

    You’ll create an after insert trigger on tbl_Locations that inserts the new records into tbl_Events and then retrieves that Event_ID to update the tbl_Locations table.

    create trigger trLocationsInsert on dbo.tbl_Locations after insert as
    
    insert into dbo.tbl_Events (Location_ID) select Location_ID from inserted
    
    update l
    set Event_ID = e.Event_ID
    from inserted i
    inner join dbo.tbl_Locations l on i.Location_ID = l.Location_ID
    inner join dbo.tbl_Events e on l.Location_ID = e.Location_ID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following table schema - CREATE TABLE [dbo].[TEST_TABLE] ( [TEST_TABLE_ID] [int] IDENTITY(1,1) NOT
I have the following schema, which I've simplified slightly: CREATE TABLE [dbo].[Header] ( [HeaderId]
I have a table with the following schema CREATE TABLE [dbo].[personas]( [id_persona] [int] IDENTITY(1,1)
I have a table created with the following schema: CREATE TABLE [dbo].[Visualizations] ( VisualizationID
I have the following schema, which I use to ensure that a person's PhoneNumber
Suppose I have the following schema t = {name: 'John', reviews: [{sid: 1, comment:
I have the following XML Schema: <Root> <EventSet> <Event> <id> //random id </id> <time>
I have the following pseudo-SQL schema: table flight id int primary key date timestamp
I have 30m records of the following schema in couchdb. { countryIso: 'TR' ,
Say you have the following in a schema: <xsd:complexType name=shape/> <xsd:complexType name=circle> <xsd:complexContent> <xsd:extension

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.