score:1
As mentioned in comments on question, it is probably better to put your inserts into a transaction in the stored proc already called, but if you must do a trigger, this is about what it should look like. Note the specific name and then the insert being done from the INSERTED table.
ALTER TRIGGER UserProfile_CreateUser
ON dbo.UserProfile
FOR INSERT
AS
BEGIN
INSERT dbo.Users (UserID)
SELECT ProfileID
FROM INSERTED
END
GO
For more info on virtual tables: http://msdn.microsoft.com/en-us/library/ms191300.aspx
More questions
- Table relation with stored procedure and trigger
- Trigger AFTER INSERT, UPDATE, DELETE to call stored procedure with table name and primary key
- Stored Procedure and populating a Temp table from a linked Stored Procedure with parameters
- How To Create Generic SQL Server Stored Procedure To Perform Inserts Into Audit Table Based on Inserted and Deleted In Trigger
- SQL Server Import and Export wizard gives invalid object error on stored procedure with temp table
- SQL Server stored procedure store 2 table variable in 1 table with from and to values
- what is dynamic stored procedure ? what is their relation with dynamic functions and dynamic queries?
- T-SQL: create stored procedure to update column in table with table and field as params in
- How to call stored procedure with both of table value and scalar parametter in entity framework
- Table Audit Trigger with Stored Procedure ID
- Stored procedure with table name and values as parameters
- Loop through all the rows of a temp table and call a stored procedure for each row
- Using temp table with exec @sql in stored procedure
- Creating stored procedure with declare and set variables
- SSIS Stored Procedure uses Temp Table 2008 and 2014
- Running a stored procedure with NodeJS and MSSQL package error
- Can't create stored procedure with table output parameter
- Stored Procedure to Insert Data from one table to another with same column names
- Stored procedure with named parameter and calculation
- SQL Server stored procedure creating temp table and inserting value
- Stored procedure with table name as parameter amongst others
- Insert data in to table using xml and stored procedure in SQL Server 2008
- How to call stored procedure with table valued parameter from .net core Entity Framework
- How do I loop through a temp table in a stored procedure with no pk
- Insert list of values into a SQL Server table with stored procedure
- Python call sql-server stored procedure with table valued parameter
- how to perform sorting and filtering in stored procedure with performance optimization?
- Stored Procedure update with parameter a column name from a different table
- Populate Dataset With Table Names From Stored Procedure
- how to execute a stored procedure and store results in temp table for unknown schema
More questions with similar tag
- Hibernate reverse engineering in eclipse from SQL Server Express R2
- Sql error in android with eclipse
- Best Way to Keep Page View Count in SQL Server
- How to check multiple id's from results IN multiple id columns in a row in SQL?
- How to Inner join with query expression crm
- [DBNETLIB][ConnectionOpen (SECCreateCredentials()).]SSL Security error
- SQL Server, not inserting records in correct position after deleting one or more records
- C# fastest way to insert data into SQL database
- Is it possible to insert wrong info in the MsSql database when we use transactions
- Connecting to SQL Server with ActiveRecord
- "Invalid column name" error when using data migration scripts
- Issues with T-SQL TRY CATCH?
- User input registration then geocoded into database
- Write a query to swap values in a table in SQL Server?
- How to connect to a sql database using classic asp?
- Can I clean up this XML query?
- 900 byte index size limit in character length
- SQL Server: Importing database from .mdf?
- How to determine if insert or update
- SQL I want to get the following output
- SQL JOIN not showing NULL results when WHERE clause used
- Use a Select Statement within a wildcard where clause
- Conditional Joins in Sql Server based on variable
- Should I consider migrating from SQL Server to Oracle for my ASP.NET applications?
- Slow paging with SQL query (stored procedure) in SQL Server
- SQL server CASE error appear
- How to sum SSRS Matrix Columns on Row Group
- How to know how many times a record has been viewed (SELECTED)?
- Random order set to certain date
- EF Core 5 - New Migrations Adding Alter ColumnStatements For Every Identity Column
Source:
stackoverflow.com