Showing posts with label internet. Show all posts
Showing posts with label internet. Show all posts

Friday, March 23, 2012

HELP! Problem in my code

I am very new to SQL and so far have overcome all my problems with reference books and the internet.

However, I am creating a report which doesn't like something in my code (I'm pretty sure it's connected with the second derived table I've added, as without it the report runs okay, although not with the results I expect to see) and I cannot figure out why.

When I try to preview the report I get this error:

Invalid Object Name 'UNIDATA_PLANNINGL_1'.

So far my code is like this:

SELECT DISTINCT
UNIDATA_PLANNING.R0 AS [Job Record], SUBSTRING(UNIDATA_PLANNINGL.R0, 1, 3) AS [Op No], UNIDATA_PLANNINGL.R1 AS [Op Description],
UNIDATA_PLANNINGL.R43 AS [T/O], UNIDATA_WIP.R0 AS [Job No], UNIDATA_PLANNING.ASSY AS Route, SUBSTRING(UNIDATA_PLANNINGL_1.R0, 1,
3) AS [Assy Op], UNIDATA_PLANNINGL_1.R1 AS [Op Description], UNIDATA_PLANNINGL_1.R43 AS [T/O], derivedtbl_1.OPTRIG1,
UNIDATA_PLANNINGL.R0 AS INVISIBLE2, UNIDATA_PLANNINGL_1.R0 AS INVISIBLE
FROM UNIDATA_PLANNINGL INNER JOIN
UNIDATA_WIPL ON UNIDATA_PLANNINGL.R0 = UNIDATA_WIPL.JOBPLKEY INNER JOIN
UNIDATA_WIP ON UNIDATA_WIPL.R2 = UNIDATA_WIP.R0 INNER JOIN
UNIDATA_PLANNING ON UNIDATA_PLANNINGL.Assy = UNIDATA_PLANNING.R0 INNER JOIN
UNIDATA_PLANNINGL AS UNIDATA_PLANNINGL_1 ON UNIDATA_PLANNING.ASSY = UNIDATA_PLANNINGL_1.Assy AND
SUBSTRING(UNIDATA_PLANNINGL.R0, 1, 3) = SUBSTRING(UNIDATA_PLANNINGL_1.R0, 1, 3) AND
UNIDATA_PLANNINGL.R43 <> UNIDATA_PLANNINGL_1.R43 INNER JOIN
(SELECT R0, SUBSTRING(R0, 1, 3) AS OP1, SUBSTRING(R0, 1, 3) + R43 AS OPTRIG1
FROM UNIDATA_PLANNINGL AS UNIDATA_PLANNINGL_2) AS derivedtbl_1 ON UNIDATA_PLANNINGL.R0 = derivedtbl_1.R0 INNER JOIN
(SELECT UNIDATA_PLANNINGL_1.R0, SUBSTRING(UNIDATA_PLANNINGL_1.R0, 1, 3) AS OP2, SUBSTRING(UNIDATA_PLANNINGL_1.R0, 1, 3)
+ UNIDATA_PLANNINGL_1.R43 AS OPTRIG2
FROM UNIDATA_PLANNINGL_1 AS UNIDATA_PLANNINGL_1_1) AS derivedtbl_2 ON UNIDATA_PLANNINGL_1.R0 = derivedtbl_2.R0
WHERE (UNIDATA_PLANNINGL.R0 LIKE N'%JOB\%') AND (NOT (UNIDATA_PLANNING.ASSY LIKE N'%2-%'))
ORDER BY [Job Record]

Could someone more experienced please explain what I have done wrong and if there is a way to fix it?

Thanks,

CPH

Derived table 2

(SELECT UNIDATA_PLANNINGL_1.R0, SUBSTRING(UNIDATA_PLANNINGL_1.R0, 1, 3) AS OP2, SUBSTRING(UNIDATA_PLANNINGL_1.R0, 1, 3)
+ UNIDATA_PLANNINGL_1.R43 AS OPTRIG2
FROM UNIDATA_PLANNINGL_1 AS UNIDATA_PLANNINGL_1_1) AS derivedtbl_2

You alias the table as UNIDATA_PLANNINGL_1_1 then reference it in the select list as UNIDATA_PLANNINGL_1

In future if you get these warnings, pull out any sub queries and test them independantly. You might also want to use something more meaningfull to alias the table names with but thats your choice

|||

Sam,

Thanks for your quick response. However, the alias UNIDATA_PLANNINGL_1_1 is something VS2005 does. If I amend it to UNIDATA_PLANNING_1 which is the table I have included VS2005 immediately changes it back to UNIDATA_PLANNINGL_1_1.

You're right about the table names, though, but unfortunately that's out of my hands.

Thanks again,

Chris

|||

also in that 2nd derived table - you select from UNIDATA_PLANNINGL_1. Is this a table? you use that name as an alias further up which AFAIK will have no scope inside the sub query.

The query should be:

(SELECT UNIDATA_PLANNINGL_1.R0, SUBSTRING(UNIDATA_PLANNINGL_1.R0, 1, 3) AS OP2, SUBSTRING(UNIDATA_PLANNINGL_1.R0, 1, 3)
+ UNIDATA_PLANNINGL_1.R43 AS OPTRIG2
FROM UNIDATA_PLANNINGL AS UNIDATA_PLANNINGL_1) AS derivedtbl_2

|||

Sam,

Thanks again for your reply and your help. As I have the table UNIDATA_PLANNINGL twice in the query VS2005 has aliased the second occurence of the table as UNIDATA_PLANNINGL_1. I have used multiple occurrences of same tables before without any problem, but this is the first time I've tried adding derived tables.

I have tried your suggestion which has cleared the error.

Your help is much appreciated, thanks again,

Chris

Friday, March 9, 2012

HELP! Can't delete merge replication subscribers in 2005

My client is using SQL 2005 Workgroup Edition. About 18-20 users will be
merge replication subscribers over the Internet with web synchronization.
During testing, several subscriptions were created and they will not drop
with the normal drop stored procedures.
This is an urgent problem because with my bogus, testing subscriptions
there, we have reached the 25 subscription limit and we cannot get their
final users subscribed.
I've seen others having this problem but haven't seen the resolution. Any
help would be greatly appreciated.
Thanks!
I take it you have tried to drop them using sp_dropmergesubscription and
sp_dropmergepullsubscription correct?
If so you should be able to drop them by deleting the contents of the
following tables on your subscriber db.
sysmergesubscriptions
MSmerge_supportability_settings
MSmerge_log_files
MSmerge_replinfo
MSmerge_supportability_settings
MSmerge_log_files
MSrepl_errors
MSmerge_history
MSmerge_articlehistory
MSmerge_sessions
MSmerge_replinfo
sysmergearticles
sysmergepublications
sysmergepartitioninfo
sysmergepartitioninfoview
sysmergeschemaarticles
sysmergeextendedarticlesview
sysmergeschemachange
sysmergesubsetfilters
sysmergesubscriptions
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Shannon Willison" <Shannon Willison@.discussions.microsoft.com> wrote in
message news:2ABD7D82-C738-4547-A9F6-DF29202DF39F@.microsoft.com...
> My client is using SQL 2005 Workgroup Edition. About 18-20 users will be
> merge replication subscribers over the Internet with web synchronization.
> During testing, several subscriptions were created and they will not drop
> with the normal drop stored procedures.
> This is an urgent problem because with my bogus, testing subscriptions
> there, we have reached the 25 subscription limit and we cannot get their
> final users subscribed.
> I've seen others having this problem but haven't seen the resolution. Any
> help would be greatly appreciated.
> Thanks!

Monday, February 27, 2012

HELP!

Report services has suddenly refused all access from Internet Explorer (Error
403 - Forbidden).
The only change that has been made to IIS recently (that I am aware of but
others have access as well) is an upgrade from PHP 4 to PHP 5 but other
websites on the same server appear to be working correctly so I'm not
convinced this is the cause of the problem.
Can anyone please shed some light on this or atleast point me in the right
direction to avoid my having to re-install from scratch.
Thanks for any advice.
Ray HojkaWas Reporting Services installed to the default web site?
Perhaps the PHP upgrade program decided to "help" you out with your security
permissions in IIS ?|||Hi Al
Yes RS was installed to the default website. Do you have any idea what
permissions could have been changed. As far as I can tell everything looks
ok on that front but I could well be wrong.
"Al" wrote:
> Was Reporting Services installed to the default web site?
> Perhaps the PHP upgrade program decided to "help" you out with your security
> permissions in IIS ?