Re: Using 'Execute SQL Task' to insert rows



Hi there Allan,

Yes, I see what you mean.

However, I can't see where I've used anything like an = in my example.
I still can't see why this error message is relevant to my SQL.

Am I going the right way about trying to copy a number of rows from one
table to another?

Cheers,
Pete

--
Cheers,
Foss


"Allan Mitchell" wrote:

> The parse will only tell you that the query is not syntactically rubbish
>
> What the runtime is telling you is that in your subquery you have said
> something similar to
>
>
> select * from dbo.MyTableWHERE Col1 = (select 1 union select 2)
>
> This is bad because you cannot have a value on the left == two values on the
> right. If I change this to
>
> select * from dbo.MyTableWHERE Col1 IN (select 1 union select 2)
>
> Then we are back up and working.
>
> Does this help you pinpoint the error?
>
>
>
> --
>
>
>
> Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
> www.SQLDTS.com - The site for all your DTS needs.
> www.SQLIS.com - You thought DTS was good. here we show you the new stuff.
> www.konesans.com - Consultancy from the people who know
>
>
> "Foss" <Foss@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:71B04E5C-7511-4F85-B156-26A462CD783F@xxxxxxxxxxxxxxxx
> > Hi there all,
> >
> > I'm trying to insert a number of rows into a table using the results of a
> > sub-query to populate them.
> > They're both on the same connection.
> >
> > When I parse this, it's fine. When I execute it, I get this message:
> > "Error Source : Microsoft OLE DB Provider for SQL Server'
> >
> > Error Description : The statement has been terminated.
> > Subquery returned more than 1 value. This is not permitted when the
> > subquery
> > follows =, !=, <, <=, >, >= or when the subquery is used as an
> > expression."
> >
> > What am I doing wrong?!
> > Here's my SQL statement:
> >
> > ----------------------------------------
> > INSERT INTO dbo.ExportUpdates
> > (exup_collisionID, exup_addedat)
> > SELECT DISTINCT col_id, GETDATE() AS CurrDate
> > FROM dbo.Collisions
> > ----------------------------------------
> >
> > I'm going quite mad looking at this so any help would be much appreciated!
> >
> > Cheers,
> > Foss
>
>
>
.



Relevant Pages

  • Re: Parameter Passing
    ... with which I am familiar is an SQL statement that is embedded in another SQL ... Perhaps it is just a matter of terminology, ... What I mean by pickup the subquery, is that the result of the subquery ...
    (microsoft.public.access.reports)
  • Re: Avoid a subselect "where not equal to"?
    ... I think this query can scale very well, ... will normally execute much faster than the subquery method ... different version of Oracle may handle the SQL ... possibly rewriting the SQL statement into a more ...
    (comp.databases.oracle.misc)
  • Query Multiple Tables
    ... Actually the subquery is just pure sql language, ... query, switch to SQL view, copy the text, and then paste ... >DMax in a query criteria in the same way. ...
    (microsoft.public.access.queries)
  • Re: SQL string problem
    ... clean up your parameters before sending them to SQL. ... > You must "escape" any single quotes when sending SQL statements ... > Just pass your SQL statement through this function when opening your ... >> Here is the full SQL statement that is assigned to the strSQL ...
    (microsoft.public.excel.programming)
  • Re: SQL Statement or Cursor
    ... > Your post seems to ask whether you're better off using a cursor or a sql ... > you can achieve this in a SQL Statement, but I'll offer a caution to you ... SQL Server's tsql doesn't have a rownum ... >> Initial Result Set but lacking Incrementing number. ...
    (microsoft.public.sqlserver.programming)