No need for a separate SELECT…
INSERT INTO table (name)
OUTPUT Inserted.ID
VALUES('bob');
This works for non-IDENTITY columns (such as GUIDs) too
More Related Contents:
- Is it possible to write single query on two table which are not connected to each other?
- sql server 2008 management studio not checking the syntax of my query
- Split function equivalent in T-SQL?
- Querying data by joining two tables in two database on different servers
- Is having an ‘OR’ in an INNER JOIN condition a bad idea?
- Where value in column containing comma delimited values
- How to find all connected subgraphs of an undirected graph
- How to use table variable in a dynamic sql statement?
- SQL query to split column data into rows
- Bulk DELETE on SQL Server 2008 (Is there anything like Bulk Copy (bcp) for delete data?)
- Create Trigger to log SQL that affected table?
- Transfer data from one database to another database
- How to find third or nᵗʰ maximum salary from salary table?
- SQL “between” not inclusive
- Can I set ignore_dup_key on for a primary key?
- Selecting first row per group
- Using PIVOT in SQL Server 2008
- sql group by only rows which are in sequence
- Function in SQL Server 2008 similar to GREATEST in mysql?
- How to retrieve field names from temporary table (SQL Server 2008)
- When using GETDATE() in many places, is it better to use a variable?
- SQL Server SELECT INTO @variable?
- How do I change db schema to dbo
- How to subtract 30 days from the current date using SQL Server
- Count records for every month in a year
- SQL Server: +(unary) operator on non-numeric Strings
- Use one CTE many times
- How to Select Every Row Where Column Value is NOT Distinct
- How to do a case sensitive GROUP BY?
- How to automatically generate unique id in SQL like UID12345678?