Re: INSERT Problem

From: Gustavo (anonymous_at_discussions.microsoft.com)
Date: 07/28/04


Date: Wed, 28 Jul 2004 12:10:15 -0700

You were right Allan. SQL told me that it was not a valid
function. I corrected it and it works now.
Thanks a million
Gustavo
>-----Original Message-----
>This
>
> WHERE (dbo.OrderRegulation(StagingOR.TitleId,
>>> > StagingOR.YearId, StagingOR.MyIssue,
StagingOR.RetId,
>>> > StagingOR.IssueId) IS NULL)
>
>is invalid syntax in SQL Server. To me that would look
like the calling of
>a function.
>
>--
>--
>
>Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
>www.SQLDTS.com - The site for all your DTS needs.
>www.konesans.com - Consultancy from the people who know
>
>
>"Gustavo" <anonymous@discussions.microsoft.com> wrote in
message
>news:5d9f01c474c7$11281550$a301280a@phx.gbl...
>> Thanks for the response Allan, but the syntax of my
query
>> parses ok. It's just that I keep getting the error
>> message that the table OrderRegulation that already
>> exists is an invalid object.
>> Does the method require to create the tables as you did
>> in your query?
>> Thanks
>> Gustavo
>>
>> >-----Original Message-----
>> >forget the
>> >
>> >OR rt.Col3 IS NULL
>> >
>> >
>> >in the INSERT. My hand got carried away.
>> >--
>> >--
>> >
>> >Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
>> >www.SQLDTS.com - The site for all your DTS needs.
>> >www.konesans.com - Consultancy from the people who
know
>> >
>> >
>> >"Allan Mitchell" <allan@no-spam.sqldts.com> wrote in
>> message
>> >news:ehpYvuLdEHA.1424@tk2msftngp13.phx.gbl...
>> >> Ok
>> >>
>> >> Let me offer an example
>> >>
>> >> CREATE TABLE Staging(col1 int, col2 int, col3 int,
>> primary key(col1,col2))
>> >> CREATE TABLE RealTable(col1 int, col2 int, col3 int,
>> primary
>> >key(col1,col2))
>> >> INSERT Staging VALUES(1,2,3)
>> >>
>> >> INSERT RealTable(col1,col2,col3)
>> >> SELECT s.col1,s.col2,s.col3
>> >> FROM Staging s LEFT OUTER JOIN RealTable rt
>> >> ON s.col1 = rt.col1 AND s.col2 = rt.col2
>> >> WHERE rt.col1 IS NULL OR rt.col2 IS NULL OR rt.Col3
IS
>> NULL
>> >>
>> >> INSERT Staging Values(1,3,2)
>> >>
>> >>
>> >> INSERT RealTable(col1,col2,col3)
>> >> SELECT s.col1,s.col2,s.col3
>> >> FROM Staging s LEFT OUTER JOIN RealTable rt
>> >> ON s.col1 = rt.col1 AND s.col2 = rt.col2
>> >> WHERE rt.col1 IS NULL OR rt.col2 IS NULL OR rt.Col3
IS
>> NULL
>> >>
>> >> SELECT * FROM RealTable
>> >>
>> >>
>> >>
>> >> --
>> >> --
>> >>
>> >> Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server
MVP)
>> >> www.SQLDTS.com - The site for all your DTS needs.
>> >> www.konesans.com - Consultancy from the people who
know
>> >>
>> >>
>> >> "Gustavo" <anonymous@discussions.microsoft.com>
wrote
>> in message
>> >> news:5c9b01c474ba$20b46990$a301280a@phx.gbl...
>> >> > Hi All(an):
>> >> > As I was advised I created this query:
>> >> >
>> >> > USE ipd
>> >> >
>> >> > INSERT INTO dbo.OrderRegulation
>> >> > (TitleId,YearId, MyIssue, RetId, IssueId,
Location,
>> Draw,
>> >> > Reorder, [Returns], Cost, Price)
>> >> >
>> >> > SELECT StagingOR.TitleId, StagingOR.YearId,Stagin
>> >> > gOR.MyIssue, StagingOR.RetId, StagingOR.IssueId,
>> >> > StagingOR.Location, StagingOR.Draw,
>> >> > StagingOR.Reorder,
StagingOR.
>> >> > [Returns], StagingOR.Cost, StagingOR.Price
>> >> > FROM StagingOR LEFT OUTER JOIN
>> >> > OrderRegulation ON
>> >> > StagingOR.TitleId = OrderRegulation.TitleId AND
>> >> > StagingOR.YearId = OrderRegulation.YearId AND
>> >> > StagingOR.MyIssue =
>> >> > OrderRegulation.MyIssue AND StagingOR.RetId =
>> >> > OrderRegulation.RetId AND
>> >> > StagingOR.IssueId =
>> >> > OrderRegulation.IssueId
>> >> > WHERE (dbo.OrderRegulation(StagingOR.TitleId,
>> >> > StagingOR.YearId, StagingOR.MyIssue,
StagingOR.RetId,
>> >> > StagingOR.IssueId) IS NULL)
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > that keeps returning the following error:
>> >> >
>> >> > Server: Msg 208, Level 16, State 1, Line 4
>> >> > Invalid object name 'dbo.OrderRegulation'.
>> >> >
>> >> > I am 1000% sure that the table exists and is not
>> >> > mispelled, the query syntax checks ok and I still
>> get the
>> >> > error.
>> >> > What is wrong??
>> >> > Thanks in advance
>> >> > Gustavo
>> >> >
>> >>
>> >>
>> >
>> >
>> >.
>> >
>
>
>.
>



Relevant Pages

  • Re: Iterative loop through SQL expression
    ... Allan: ... I was able to accomplish this with help from your book, "Pro SQL 2005 IS", ... with an Execute SQL Task, a Script Task, and the ForEach ... I've tried to set up the ForEach Loop ...
    (microsoft.public.sqlserver.dts)
  • Re: Problem with SQL Task in MS SQL Server DTS package
    ... I'm not an SQL expert but it looks to me like I'm using the ... How could I word my query without the aliases? ... "Allan Mitchell" wrote: ... DTS is unable to offer you ...
    (microsoft.public.sqlserver.dts)
  • Alter User for domain user
    ... SQL 2005: If I try to do this: ... I get a message that says "invalid syntax near '\'". ... The syntax for ALTER USER says that the first parameter is the user name, ... The underlying issue is that I'm trying to assign a default schema to the ...
    (microsoft.public.sqlserver.security)
  • Re: Dynamic Query Order in DTS
    ... are you using the Dynamic Properties task for something else because you do ... Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) ... >> I support PASS - the definitive, global community ...
    (microsoft.public.sqlserver.dts)
  • Re: Week number and day number...
    ... >> enter this sql, ... >> "The expression you entered contains invalid syntax, ... DatePart takes a string as the first parameter. ...
    (microsoft.public.access.queries)