Re: Using 'Execute SQL Task' to insert rows

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi there,

Don't worry, it was the DBA's fault all along! He set up a trigger on the
table wrong..

Thanks anyway!

Cheers,
Foss


"Foss" wrote:

> 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: Using Execute SQL Task to insert rows
    ... Foss, I read your question and I don't see the subquery in the example you ... Microsoft OLE DB Provider for SQL Server' ... > Here's my SQL statement: ...
    (microsoft.public.sqlserver.dts)
  • RE: Using Execute SQL Task to insert rows
    ... Sorry, I'm very new to all this, when I said subquery I was referring to the ... Pete ... "frank chang" wrote: ... > Foss, I read your question and I don't see the subquery in the example you ...
    (microsoft.public.sqlserver.dts)
  • RE: Using Execute SQL Task to insert rows
    ... He set up a trigger on the ... "Foss" wrote: ... > Hi Frank, ... > Sorry, I'm very new to all this, when I said subquery I was referring to the ...
    (microsoft.public.sqlserver.dts)