» How do I insert multiple rows WITHOUT repeating the "INSERT INTO dbo.Blah" part of the statement?
How do I insert multiple rows WITHOUT repeating the "INSERT INTO dbo.Blah" part of the statement?
|April 12, 2010
Posted by forumadmin
I know I’ve done this before years ago, but I can’t remember the syntax, and I can’t find it anywhere due to pulling up tons of help docs and articles about “bulk imports”.
Here’s what I want to do, but the syntax is not exactly right… please, someone who has done this before, help me out
INSERT INTO dbo.MyTable (ID, Name)
VALUES (123, 'Timmy'),
I know that this is close to the right syntax. I might need the word “BULK” in there, or something, I can’t remember. Any idea?
EDIT: Particularly, I need this for a SQL Server 2005 database. I’ve tried this code, to no avail:
DECLARE @blah TABLE
ID INT NOT NULL PRIMARY KEY,
Name VARCHAR(100) NOT NULL
INSERT INTO @blah (ID, Name)
VALUES (123, 'Timmy')
VALUES (124, 'Jonny')
VALUES (125, 'Sally')
SELECT * FROM @blah
Incorrect syntax near the keyword 'VALUES'.
More Related Questions
- How to SELECT * INTO [temp table] FROM [stored procedure] How do I do a SELECT * INTO [temp table] FROM [stored procedure]? Not FROM [Table] and without defining [temp table]?
Select all data from BusinessLine into tmpBusLine works fine.
- Drop all the tables, stored procedures, triggers, constraints and all the dependencies in one sql statement Is there any way in which I can clean a database in SQl Server 2005 by dropping all the tables and deleting stored procedures, triggers, constraints and all the dependencies in one SQL […]
- SQL Server – pull X random records per state I have a table with records for each zip code in the united states. For the purposes of displaying on a map, I need to select X random records per state. How would I go about doing […]
- How do I create unique constraint that also allows nulls in sql server Adding a column to table, and I want a unique constraint, so the column will insert GUID's, but to allow for existing data before column was added, I need to allow for NULL's in the […]
- How can I do an UPDATE statement with JOIN in SQL? I need to update this table in MS SQL Server 2005 with data from its 'parent' table, see below:
- How to remove diagramming support objects from SQL Server? I need to remove diagramming support tables, stored procs, views, etc from SQL Servrer using TSQL script.
Is there such a script available?
SQL 2005 and 2008. Asked By - […]
- How to retrieve unique records having unique values in two columns from a table in SQL Server I want to query a table where I need the result that contains unique values from two columns together. For e.g.
EnquiryId | EquipmentId | […]
- SQL update query using joins I have to update a field with a value which is returned by a join of 3 tables.
,im.sku as iSku
,gm.SKU as GSKU
,mm.ManufacturerId as ManuId
- sp_replmonitorsubscriptionpendingcmds into a table [How2] Im looking to making a job that will tell me the number of pending cmd's on the replication,
Im using sp_replmonitorsubscriptionpendingcmds and im trying my best to put it into a […]
- 8078 bytes in 8060 B datapage (SQL Server)? It is written everywhere that data in SQL Server is written in pages of 8K (8192 B) each with 8060 bytes for data and the rest is overhead (system info).
Though, the recent article  […]