How to make SQL Management Studio see new table? - sql

I am using SQL server 2008. If I am working on the Management Studio's query analyser, and I go ahead and create a new table or view, then the SSMS does not see the newly created object for intellisense.
What do I do to make SSMS see and autosuggest from the newly created tables/views too?

Have you tried to refresh the intellisense cache
Edit -> Intellisense -> Refresh Local Cache (CTRL+Shift+R)

Go to the menus:
Edit > Intellisense > Refresh local cache
or press the shortcut key: Ctrl-Shift-R

Related

SQL server update dbo refresh

How come SQL server 2014 intellisense doesn't recognize recently created database objects (E.g. view, table, etc.), yet a query can be ran using such objects?
Is this a bug?
The intellisense cache is built when you open a connection in the Query Editor of SQL Server Management Studio. But unfortunately the intellisense cache is not rebuilt after creating objects, and hence it is not refreshed until you press the shortcut Ctrl+Shift+R suggested by Simon.
If you like to use a mouse, enter here

SQL Server intellisense does not refresh stored procedure and function list

I am trying to learn Microsoft SQL server 2014. I have defined some functions and stored procedures, but SQL server intellisence does not show latest ones and underlines them as an error.
Although SQL server shows as an error when I execute it works fine. My question is why SQL server underlines the statement, even though it works.
This will happen any time you create a new table, procedure, function, etc or modify a database object (add/remove columns on a table for example).
You just need to refresh the Intellisense cache to have it look for new objects. ctrl+shift+r should do the trick, or use the menu option Edit > Intellisense > Refresh Local Cache as one of the comments suggested
To refresh the intellisense so it incorporates your latest stored procedures or table changes:
Open any stored procedure (right-click and choose Modify)
From the Menu, choose Edit > Intellisense > Refresh Local Cache
That should do it!

Text editor SQL Microsoft Management Studio 2012

I've created and succesfully compiled new procedure in SQL Microsoft Management Studio 2012.
After that I want to use it in other procedure like exec my_new_procedure.
It works perfect and procedure compiled as well, but in editor of Microsoft Management Studio 2012 my procedure call (exec my_new_procedure) underlined with red line as called procedure is not exists.
Situation is fixed after I close and run again Microsoft Management Studio.
How can fix it without reload Microsoft Management Studio?
once you create a new SQL Server object, your newly created object does not get updated in the IntelliSence Local Cache and due to this, it shows red line underneath that object. So you just need to refresh SSMS IntelliSence Local Cache and once you refresh it, IntelliSence will automatically add newly created object in the cache and the red line will disappear. try this
Edit -> IntelliSense -> Refresh Local Cache
or simply do
Ctrl + Shift + R

How to change the connection in Sql Server Data Tools Editor in Visual Studio

My goal is to keep SQL Server stored procedures under source control. I also want to stop using SQL Server Management Studio and use only Visual Studio for SQL related development.
I've added a new SQL Server Database project to my solution. I have successfully imported my database schema into the new project, and all the SQL objects (tables, stored procedures) are there in their own files.
I know that now if I run (with F5) the .sql files then my changes will be applied to my (LocalDB). This if fine, but what if I want to very quickly run something on another machine (like a dedicated SQL Server shared by the entire team)? How can I change the connection string of the current .sql file in the Sql Server Data Tools editor?
I have the latest version of Sql Server Data Tools extension for Visual Studio 2012 (SQL Server Data Tools 11.1.31203.1). I don't know if this is related to the current version, but I cannot find anymore the Transact-SQL Editor Toolbar.
I have also tried to Right-click on the sql editor, choose Connection -> Disconnect. If I do the reverse (Connection -> Connect...) the editor directly connects automatically (probably to my LocalDB), without asking me a dialog to choose my connection.
Another strange thing I've observed, if I try to run a simple SQL query (like select * from dbo.ApplicationUser I receive the following message (even if the autocomplete works):
Thanks.
(Note: I have the same issue with Visual Studio 2013)
Inspired by srutzky's comments, I installed the latest SSDT pack (12.0.41025). And bingo, like srutzky said there is a Change Connection option. But what's more, you can specify your Target DB by right clicking on the Project in the Solution Explorer, and going to Properties->Debug and changing the Target Connection String! If you're stuck on an older SSDT, then the below instructions will still work.
For SSDT 12.0.3-
I've also been plagued by this problem! My solution is below, but it has some Pros and Cons to it...
SOLUTION
I'm assuming that you are using a SQL Server Project in VS (I'm using VS2013 and SQL Server 2012).
Right click on your .sql file in the Solution Explorer and view Properties.
Change Build Action to None.
If the file is open for editing, then close it.
Reopen the file, and the T-SQL Editor should appear at the top.
Click Connect, and you will connect to your (localdb).
Click Disconnect.
Click Connect again and the SQL Server Connection dialog should appear.
Switch the connect string of '(localdb)\Whatever' to '.' (for some reason using '(localhost)' didn't work for me).
Voila, you should now be able to query against your SQL Server DBs! Rinse and repeat for every file you want this capability with... :/
PROS
You can finally run queries directly against your SQL Server DB
Your code can be organized in a nice VS solution (SSMS doesn't allow folders! :/)
You can (after switching Build Action setting back) Build the project
CONS
I'm not seeing any autocomplete/intellisense against the remote DB, although if you import your DB, then you could gain the intellisense from that
Requires each file to switch Build Action to None
This should be a fairly simple and straight-forward thing to do, that is, if you are using SSDT version 12.0.41025.0 (or newer, one would suppose):
Do either:
Go to the SQL menu at the top of the Visual Studio window
Right-click inside of the SQL editor tab
Go to Connection ->
Select Change Connection
Then it will display the "Connect to Server" modal dialog window.
If you do not see the options for "Disconnect All Queries" and "Change Connection...", then you need to upgrade your SSDT via either:
Visual Studio:
Go to the "TOOLS" menu and then "Extensions and Updates..."
Direct download:
Go to: http://msdn.microsoft.com/en-us/data/tools.aspx
The fastest way to achieve this is create a new SQL Connection, copy and paste the code then execute.
What I do is Tools->SQL Server->New Query.
Enter the database credentials (And make sure that the Database at the top is correct - I have hundreds of sp's in my master db on local :) )
Copy the source code from the editor, paste into the new query window.
Then Execute (CRTL-Shift-E).
You can leave this 'scratch' window open and pinned for easy access for subsequent executes.
If you want to deploy (i.e. publish) the entire database then you can setup a publish destination for each server, right click on the xml and select publish..

SSMS 2012 intellisense Refresh Local Cache disabled

I've read all sorts of suggestions about how to get intellisense to work in SSMS 2012, and one suggestion I see everywhere is to refresh the local cache. When I go to Edit - Intellisense, the Refresh Local Cache item is disabled. I have a query window open and pointed to a SQL 2012 database. What am I missing?