I have the following query: -
SET QUOTED_IDENTIFIER ON
-
GO
-
SET ANSI_NULLS ON
-
GO
-
-
ALTER PROCEDURE YourProcedure AS
-
-
insert into msbtotal.dbo.newclients
-
SELECT tcms_members.dbo.memberdata.* FROM tcms_members.dbo.memberdata left outer join
-
msbtotal.dbo.memberdata on tcms_members.dbo.memberdata.id =
-
msbtotal.dbo.memberdata.id where msbtotal.dbo.memberdata.id is
-
null
-
GO
-
SET QUOTED_IDENTIFIER OFF
-
GO
-
SET ANSI_NULLS ON
-
GO
-
And what I'm trying to do is to compare two databases on the same server to see if any new data is entered into tcms_members.dbo.memberdata compared to msbtotal.dbo.memberdata and if so, the new data is written to a table (in the msbtotal database) called "newclients." The data is checked via the ID field and if there is any new data in the tcms_members.dbo.memberdata, it will be evident by there being a new ID number. The query runs fine and I tried adding "sample" data into the database to have it inserted into the new client table and that sample data wasnt added BUT I also didn't receive any errors. I can provide the sample data if necessary but I was wondering if anyone can see anything wrong with my query that may cause this? The server is a SQL 2000 server and I am running the query as the admin on the server, just as an fyi.
Thank you
Doug
CK,
I created a new table (newclients2) and inserted the data. For whatever reason that worked. It seems that the table "newclients" had something wrong with it, but I've fixed that and it seems to work correctly.
Thanks for your help.
Doug
22 2141
A quick debugging question - do you get any results when you run just the select statement ?
And...
If it's a simple check of record existence, an EXISTS() function might be faster...
Happy Coding!!!
~~ CK
CK,
Does EXISTS work in SQL 2000? Also, I have ran just the select statement and it does in fact locate the "sample data."
Here's the error I get when I add the insert statement back into the query:
Server: Msg 208, Level 16, State 1, Procedure newcustomers, Line 4
Invalid object name 'msbtotal.dbo.members'.
I've checked all of the SP on this server and there is no procedure called "newcustomers." Can anyone offer any advice as to why my server is telling me that there's a procedure that doesnt really exist.
Thanks
Doug
EXISTS is part of the basic SQL language, so yes it does work
You are trying to alter a procedure called members in the database msbtotal
as it doesnt exist, it cannot alter it -- look again at the code you have -- if you cannot see it, then post it for us to debug.
I suspect you have - ALTER PROCEDURE msbtotal.dbo.members AS
instead of - ALTER PROCEDURE YourProcedure AS
QPL ... the code that I posted on my first entry is straight from my sql server. Please notice line 6. -
SET QUOTED_IDENTIFIER ON
-
GO
-
SET ANSI_NULLS ON
-
GO
-
-
ALTER PROCEDURE YourProcedure AS
-
-
insert into msbtotal.dbo.newclients
-
SELECT tcms_members.dbo.memberdata.* FROM tcms_members.dbo.memberdata left outer join
-
msbtotal.dbo.memberdata on tcms_members.dbo.memberdata.id =
-
msbtotal.dbo.memberdata.id where msbtotal.dbo.memberdata.id is
-
null
-
GO
-
SET QUOTED_IDENTIFIER OFF
-
GO
-
SET ANSI_NULLS ON
-
GO
-
Your actual procedure name is YourProcedure ? Or you change it to newcustomers?
Fix that first and let's see...
~~ CK
The procedure is called YourProcedure. I don't have a stored procedure called newcustomers. I've searched the entire server and every database on that server. There is no procedure called newcustomers.
Since you don't have a parameter, you may actually run this: -
-
SELECT tcms_members.dbo.memberdata.* FROM tcms_members.dbo.memberdata left outer join
-
msbtotal.dbo.memberdata on tcms_members.dbo.memberdata.id =
-
msbtotal.dbo.memberdata.id where msbtotal.dbo.memberdata.id is
-
null
-
-
from your Query window. See if it returns any record or gives an error.
~~ CK
Ck,
That does not give an error.
Now try this: -
-
ALTER PROCEDURE YourProcedure
-
AS
-
SELECT tcms_members.dbo.memberdata.* FROM tcms_members.dbo.memberdata left outer join
-
msbtotal.dbo.memberdata on tcms_members.dbo.memberdata.id =
-
msbtotal.dbo.memberdata.id where msbtotal.dbo.memberdata.id is null
-
-
~~ CK
CK,
That ran fine with no errors.
So, your proc has been created. Try running it.
~~ CK
Ck,
That procedure did run now we just need the insert (or exist statement)
One at a time, we're trying to isolate your problem...
Now, try to put the insert command... -
-
ALTER PROCEDURE YourProcedure
-
AS
-
insert into msbtotal.dbo.newclients
-
SELECT tcms_members.dbo.memberdata.* FROM tcms_members.dbo.memberdata left outer join
-
msbtotal.dbo.memberdata on tcms_members.dbo.memberdata.id =
-
msbtotal.dbo.memberdata.id where msbtotal.dbo.memberdata.id is null
-
-
Then run your proc...
~~ CK
CK,
here's the error when I run my proc:
Server: Msg 208, Level 16, State 1, Procedure newcustomers, Line 4
Invalid object name 'msbtotal.dbo.members'.
And you run it in a new query window, not being called inside another proc? Are you in the same DB? Are you calling any other proc? What version of ms sql server are you using?
~~ CK
Nope, the query is ran in a new query window. I am in the same db. I am not calling any other proc and this is running on a SQL 2000 server.
The only remaining thing that I can think of is to list the column names that you are populating on the INSERT clause and the corresponding column name you are trying to insert to the table on the SELECT clause.
You might also want to create a copy of newclients table with a different name and insert it to that table instead.
Are you using any CALCULATED columns? Functions? Triggers? Constraint? etc?
~~ CK
I can try to create a new table and insert it into that but in answer to your other question, I'm not using any other triggers, or constraints or any calculations.
Doug
CK,
I created a new table (newclients2) and inserted the data. For whatever reason that worked. It seems that the table "newclients" had something wrong with it, but I've fixed that and it seems to work correctly.
Thanks for your help.
Doug
Sign in to post your reply or Sign up for a free account.
Similar topics
by: democratix |
last post by:
Hi,
I've only got a couple years experience developing for Access but have
recently been experimenting with HTML/javascript for gui and
client-side scripting, mysql for database and php for...
|
by: Susan Lam |
last post by:
I am looking for some papers/information that compare relational
databases such as oracle, mysql, sql server etc. I am particularly
interested in their features such as locking mechanisms,...
|
by: bettervssremoting |
last post by:
To view the full article, please visit
http://www.BetterVssRemoting.com
Better VSS Remote Access Tool
This article makes a detailed comparison among SourceAnyWhere,
SourceOffSite, VSS...
|
by: Stuart Ferguson |
last post by:
I am currently in the process of making changes to an application using
a SQL Server database and have made changes to a development copy of the
live database which includes changing and adding...
|
by: aaj |
last post by:
Hi all
I have Aceess 2000 front end linking to SQLServer 2000 BE.
While developing the backend I work on an offline database. When happy I
update the live one. Any changes I've made to the...
|
by: mayamorning123 |
last post by:
A comparison among six VSS remote tools including SourceOffSite ,
SourceAnyWhere, VSS Connect, SourceXT, VSS Remoting, VSS.NET
To view the full article, please visit...
|
by: bettervssremoting |
last post by:
To view the full article, please visit
http://www.BetterVssRemoting.com
Better VSS Remote Access Tool
This article makes a detailed comparison among SourceAnyWhere,
SourceOffSite, VSS...
|
by: bcutting |
last post by:
I am looking for a way to take a large number of images and find
matches among them. These images may not be exact replicas. Images
may have been resized, cropped, faded, color corrected, etc.
...
|
by: darrel |
last post by:
Hello vb masters, am having difficulty in comparing database through my visual basic program, i'am using access database and sql statement, i'am doing a time scheduling system, so one of the thing...
|
by: AllBeagle |
last post by:
Hello Everyone,
I'm trying to build a web-based application for a client of mine and I keep finding holes in my design, so I could use some guidance if anyone has any to offer. Let me try to...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |