Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8650917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:56:10+00:00 2026-06-12T13:56:10+00:00

I am using SQL Server 2008 and Talend The problem that I am facing

  • 0

I am using SQL Server 2008 and Talend

The problem that I am facing is, I have two tables in two different Databases, they have the same fields and I am trying to query them and have certain criteria met.

The user has the correct privileges to view both tables and all.

Both tables I just need a few fields, so I created views to make life easier:
Db USA I created a view

(IN THE VIEW)

"SELECT IDCUST, NAMECUST,CODETERM,AMTCRLIMT,DATELASTIV,AMTBALDUEH
FROM TABLE!
WHERE COUNTRYCODE = 'USA' OR COUNTRYCODE ="U.S.A" //this is for USA server 
only the other doesn't have the WHERE clause. 

Now what I want to do is query this view with my other DB (‘MAIN’).

The Criteria is if the IDCUST is the same then I just want the row from ‘USA’ Database.

I Tried:

SELECT *  
FROM USA.dbo.VIEWUSA 
UNION 
SELECT *  
FROM MAIN.dbo.VIEWMAIN
WHERE MAIN.dbo.IDCUST <> USA.dbo.VIEWUSA.IDCUST

It has an error though saying USA.dbo.VIEWUSA.IDCUST was not appropriate.

I tried it as a JOIN but my join did not work at all (the max rows was around 6k and it was querying at 100k before i stopped it.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T13:56:11+00:00Added an answer on June 12, 2026 at 1:56 pm

    I think a union all is the best approach, but you need a slight tweak:

    select *
    from usa.dbo.ViewUSA
    union all
    select *
    from MAIN.dbo.VIEWMAIN vm
    where vm.idcust not in (select idcust from usa.dbo.ViewUSA)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using SQL Server 2008 (R2). I have two tables in different databases (with same
Using SQL Server 2008 R2 (Version 10.50.4000.0): I have two tables. I want to
I am using SQL Server 2008. I have a query that pulls two random
I'm using SQL Server 2008. I have two tables like this: OrderItems OrderItemID InventoryItemID
Using SQL Server 2008, suppose I have several tables with 3 common columns (not
Using SQL Server 2008, I have two stored procedures - create procedure [dbo].[SH_Export_data] (@unit
I'm using SQL Server 2008 and I have a view that looks like this:
I'm using SQL Server 2008 Express, and I have a stored procedure that do
Using SQL Server 2008, I have a requirement that email addresses in my user
I am using SQL Server 2008 and I have 4 tables StudentAbsentees, Students, StudentSections

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.