Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Insert 250,000 rows from one table to another

Author  Topic 

rternier
Starting Member

44 Posts

Posted - 2009-08-05 : 16:31:16
I'm using the following query to transfer a lot of records from one database to another:

INSERT INTO db_One..tblGPSData(numLatitude, numLongitude, datTimeStamp, intUserID, intSpeed, datClientTime)
SELECT numLatitude, numLongitude, datTimeStamp, intUserID, intSpeed, datClientTime
FROM db_Two..[tblGPSData]

To my undestanding this should work perfectly fine.

in fact, when I ran it, it incremented the index of that table (the counter) by 250,000, but didn't insert any rows.

The error I get is:

Msg 512, Level 16, State 1, Procedure UpdateGPSData, Line 7
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.

---

Now the table i'm inserting into has a trigger on it, should i disable that before inserting?





----
Killer ASP.NET ninja coding monkeys do exist!
[url]http://weblogs.asp.net/rternier[/url]

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-08-05 : 16:40:58
Since there is no subselect in your insert query I think the trigger is bad.
Disable the trigger and it should work.

But I would later have a look on that trigger because there is something going wrong in some cases.
I think the trigger isn't coded for more than one row in inserted/deleted.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2009-08-05 : 16:41:06
The question is, "What does that trigger do and why is it failing?"

Without seeing the trigger I can't make any judgments about it but a common error found in triggers is the assumption that the trigger is dealing with a single INSERT (or UPDATE, DELETE). You might want to see if that is the case and make the code more generalized. Absent that, you might want to post the trigger code and see if someone can offer something specific.

=======================================
Men build too many walls and not enough bridges. -Isaac Newton, philosopher and mathematician (1642-1727)
Go to Top of Page
   

- Advertisement -