Search
 
SCRIPT & CODE EXAMPLE
 

SQL

sql insert inserted id

-- Never use @@identity or scope_identity()
-- they can not always be relied upon

DECLARE @Ids_tbl TABLE ([id] INT); -- Requires table. use variable for scope
INSERT INTO [sometable] ([ColA],[ColB])
OUTPUT INSERTED.ID INTO @Ids_tbl(id)
VALUES ('valA','valB');

SELECT [id] FROM @Ids_tbl; -- <-- Id(s) in here

Comment

PREVIOUS NEXT
Code Example
Sql :: sql get month name 
Sql :: How to convert Varchar to Double in sql? 
Sql :: Copy Table from SQL to CSV 
Sql :: sql timestamp to date 
Sql :: SQL Modify Column in a Table 
Sql :: create unique index postgres 
Sql :: mysql date to string 
Sql :: docker open terminal mysql server 
Sql :: remove binlog mysql 
Sql :: sql missing values 
Sql :: mysql current date 
Sql :: spring import sql 
Sql :: postgresql search object in array 
Sql :: wherein mysql 
Sql :: psql change table schema 
Sql :: sql update table remove spaces 
Sql :: allow external access to mysql 
Sql :: sql add column to table 
Sql :: calculate distance between two latitude longitude postgresql 
Sql :: create pl/sql stored procedure 
Sql :: plsql triggers 
Sql :: sql select second max 
Sql :: @sqlresultsetmapping 
Sql :: get current month last date in sql server 
Sql :: how to change a column name in postgresql 
Sql :: describe table postgres 
Sql :: create table employees oracle 
Sql :: mysql set last_insert_id 
Sql :: replace null in sql 
Sql :: kill a pid redshift 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =