Try something like this:
DECLARE @userData TABLE(
name varchar(30) NOT NULL,
oldlocation varchar(30) NOT NULL
);
INSERT INTO @userData (name, oldlocation)
SELECT name, location FROM myTable
INNER JOIN otherTable ON ...
WHERE age > 30;
More Related Contents:
- Insert multiple rows WITHOUT repeating the “INSERT INTO …” part of the statement?
- SQL Server – error when creating stored procedure
- How can foreign key constraints be temporarily disabled using T-SQL?
- How can I escape square brackets in a LIKE clause?
- Does T-SQL have an aggregate function to concatenate strings? [duplicate]
- When should I use a table variable vs temporary table in sql server?
- Datatype for storing ip address in SQL Server
- Is there a way to loop through a table variable in TSQL without using a cursor?
- Maximum size of a varchar(max) variable
- best way to convert and validate a date string
- How to get a date in YYYY-MM-DD format from a TSQL datetime field?
- How do I format a number with commas in T-SQL?
- How can I INSERT data into two tables simultaneously in SQL Server?
- Is there a way to simplify a NULL compare of 2 values
- TSQL Try / Catch within Transaction or vice versa?
- What is the maximum number of characters that nvarchar(MAX) will hold?
- TSQL: Create a view that accesses multiple databases
- Sequence as default value for a column
- Aggregate bitwise-OR in a subquery
- How do I flush the PRINT buffer in TSQL?
- Get ROWS as COLUMNS (SQL Server dynamic PIVOT query)
- OR Operator Short-circuit in SQL Server
- How to change default language for SQL Server?
- T-SQL incrementing counter based on change in a column value
- Cannot bulk load. Operating system error code 5 (Access is denied.)
- comparing a column to a list of values in t-sql
- Does query plan optimizer works well with joined/filtered table-valued functions?
- Random record from a database table (T-SQL)
- What are row, page and table locks? And when they are acquired?
- time format in SQL Server