I'm working on a new script that pulls customer information and multiple databases have to be queried to get the data. However my query is failing to pull any data and I'm not sure why. Do I need to have my connection string include both databases? If so how?
This query errors.
select site_no, site_name from DATABASE1.dbo.tablename s WITH (NOLOCK) where phone1 = $strANI OR phone2 = $strANI or site_no IN (Select site_no from DATABASE2.dbo.tablename2 where phoneNumber = $strANI )
This query works fine.
select site_no, site_name from DATABASE1.dbo.tablename s WITH (NOLOCK) where phone1 = $strANI OR phone2 = $strANI
My database connection string
jdbc:jtds:sqlserver://sql.example.local/Database1:1433;instanceName=MSSQLSERVER