Solved

Syntax error in SQL Select statement

Posted on 2007-11-21
3
174 Views
Last Modified: 2010-04-21
I am trying to do an inner join and get a syntax error on my select statement.  Here is the line

"Select * from PROVIDER INNER JOIN PHYSINS ON PROVIDER.PHYSICIAN_NPI = PHYSINS.PHYSICIAN_NPI WHERE (PHYINS.INSURANCE_CARRIER_NAME = @SearchInsur"

private String SearchProviderIns
    {
        get
        {
          //  String srchCmd = "Select * from PHYSINS";
          //  String srchCmd = "Select * from PHYSINS where INSURANCE_CARRIER_NAME = @SearchInsur AND PHYSICIAN_NPI in(SELECT PHYSICIAN_NPI FROM Provider)";
           // String InsurancesrchCmd = "Select * from PHYSINS where INSURANCE_CARRIER_NAME = @SearchInsur";
           
           
           
            String InsurancesrchCmd = "Select * from PROVIDER INNER JOIN PHYSINS ON PROVIDER.PHYSICIAN_NPI = PHYSINS.PHYSICIAN_NPI";
           
           
            // InsurancesrchCmd += ProviderSearch;

            if (txtSearchInsur.Text != "")
                //InsurancesrchCmd += " where INSURANCE_CARRIER_NAME = @SearchInsur";
                InsurancesrchCmd += " WHERE (PHYINS.INSURANCE_CARRIER_NAME = @SearchInsur";

            return InsurancesrchCmd;


Any ideas are greatly appreciated.


Thanks
Kenny
0
Comment
Question by:kwh3856
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
SQL_SERVER_DBA earned 500 total points
ID: 20329106
Select *
from PROVIDER INNER JOIN PHYSINS ON PROVIDER.PHYSICIAN_NPI = PHYSINS.PHYSICIAN_NPI
WHERE PHYINS.INSURANCE_CARRIER_NAME = @SearchInsur
0
 
LVL 16

Expert Comment

by:SQL_SERVER_DBA
ID: 20329128
or

"Select *
from PROVIDER INNER JOIN PHYSINS ON PROVIDER.PHYSICIAN_NPI = PHYSINS.PHYSICIAN_NPI
WHERE PHYINS.INSURANCE_CARRIER_NAME = '" & @SearchInsur & "'"
0
 

Author Closing Comment

by:kwh3856
ID: 31410407
Thanks a bunch!!!
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question