none
SQL Server Database Project - Getting Intellisense to work

    Question

  • So,

    Basically, we do not have "SQL Projects".  WE have Scripts.  But for stupidity I do not want to get into, the only tool available to us is Visual Studio.

    So I created a "Database Project" and added my scripts to them.  Flagging them all "Build Action: None" because this isn't a project it is simply a repository for my scripts.

    So I click on a server and select the "New Query" option and I get all the Intellisensed objects from the database I connect to.

    But when I open a file associated with the project "Misc SQL", no matter what database I actually connect to, I get nothing. I get intellisense suggestions from the project but not the connected server/database.

    I want the SQL Intellisense to be based upon the connection ONLY.  I don't give a rats ass about the "project" it belongs to, that is just a place holder for managing files, not for any other purpose.

    So

    A) How can I tell the project "you are an empty shell and intellisense comes from the connection"

    or

    B) What type of project can I create that will simply be a tree of files and thus will be treated like unassociated scripts.

    Thanks

    Jaeden "Sifo Dyas" al'Raec Ruiner


    "Never Trust a computer. Your brain is smarter than any micro-chip."
    PS - Don't mark answers on other people's questions. There are such things as Vacations and Holidays which may reduce timely activity, and until the person asking the question can test your answer, it is not correct just because you think it is. Marking it correct for them often stops other people from even reading the question and possibly providing the real "correct" answer.

    Thursday, July 21, 2016 5:23 PM

Answers

  • Hi JaedenRuiner

    >>Once the project is created I create a non-build script for the project.

    >> I then connect to a database server, using windows authentication.

    Two situations are mutual independence. When you create a project and add a non-build script, you get the intellisense just as your screenshot that all tables come from your project itself, not from the service. This situation could be verified by the Weiwei Cai’s reply. In her reply, we must import a database to our project not connect to the service. So all intellisense would be the project itself and a database we import.

    >>but if i click "create new query form the SQL Server Explorer, or even from the query tool bar

    >> I then connect to the SAME database server and I get this intellisense

    In this situation, you connect to a server and not need to specify a database. So when you code the .sql file that all databases from server and all tables from master will be display in intellisense.

    You could verify these two situations by the following steps:

    1. Import a database from server to you project, and add a script. You could operate project itself and the imported database. And we could not connect to any databases from server.
    2. Connect to a database from windows authentication, and add a script. You could operate all databases from server and tables from your selected database.

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, July 26, 2016 2:28 AM
    Moderator

All replies

  • Hi  JaedenRuiner,

    >>I want the SQL Intellisense to be based upon the connection ONLY

    According to your description, when you create a SQL DataBase Project and add your scripts to them, you could not use intellisense in current project. Am I right?

    As far as I know, the database project is not related to the connection that you connected in Server Explorer. They are standalone for each other.

    If you want to operate the database that you connected in Server Explorer in your database project, please import the existed database to the new empty SQL project. In my side, I have created a new project and import a Database from SQL Server successfully, then when I add a script to my project and could operate tables from SQL Server with intellisense. My detail steps as shown in following screenshot. Then I choose import a script to my project, the result is the same as above.

    If I misunderstand, please feel free to let me know.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Saturday, July 23, 2016 3:00 AM
    Moderator
  • I'm not "importing" anything.

    IN VS2015, go to:

    Once the project is created I create a non-build script for the project.
    I then connect to a database server, using windows authentication.

    This is the Intellisense I get:

    The only db listed is the Project Name.

    but if i click "create new query form the SQL Server Explorer, or even from the query tool bar:

    I then connect to the SAME database server and I get this intellisense:

    As you can see, I am now getting intellisense from the server not from the current project.

    There has to be a setting somewhere that affects this (and I'll admit it could possibly be server side given the security we have on our network and our databases).

    Thanks

    J"SD"a'RR


    "Never Trust a computer. Your brain is smarter than any micro-chip."
    PS - Don't mark answers on other people's questions. There are such things as Vacations and Holidays which may reduce timely activity, and until the person asking the question can test your answer, it is not correct just because you think it is. Marking it correct for them often stops other people from even reading the question and possibly providing the real "correct" answer.

    Monday, July 25, 2016 4:08 PM
  • Hi JaedenRuiner

    >>Once the project is created I create a non-build script for the project.

    >> I then connect to a database server, using windows authentication.

    Two situations are mutual independence. When you create a project and add a non-build script, you get the intellisense just as your screenshot that all tables come from your project itself, not from the service. This situation could be verified by the Weiwei Cai’s reply. In her reply, we must import a database to our project not connect to the service. So all intellisense would be the project itself and a database we import.

    >>but if i click "create new query form the SQL Server Explorer, or even from the query tool bar

    >> I then connect to the SAME database server and I get this intellisense

    In this situation, you connect to a server and not need to specify a database. So when you code the .sql file that all databases from server and all tables from master will be display in intellisense.

    You could verify these two situations by the following steps:

    1. Import a database from server to you project, and add a script. You could operate project itself and the imported database. And we could not connect to any databases from server.
    2. Connect to a database from windows authentication, and add a script. You could operate all databases from server and tables from your selected database.

    Best Regards,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, July 26, 2016 2:28 AM
    Moderator