Solved

Syntax error in SQL Select statement

Posted on 2007-11-21
3
177 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

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 aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

632 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