SQL Server 2008 Management Studio doesn't recognize new Schema - sql-server-2008

I have created a new Schema in a database called Contexts. Now when I want to write a query, Management Studio doesn't recognize the tables that belong to the new Schema. It says: 'Invalid object name Contexts.ContextLibraries'...
Transact-SQL:
INSERT INTO [Contexts].[ContextLibraries] (ChannelId, [IsSystem])
VALUES (#ChannelId, 1)
When I try the same thing on my local database, it does work...
Any ideas?
I did try to change the Default schema for the user from dbo to Contexts but this doesn't work. Also checked Contexts in Schemas owned by this user without success.
Update: Apparently the sql query does work but the editor gives a fault saying the object is invalid.

Try to refresh local cache of Management Studio:
Management Studio Menu >> Edit >> IntelliSense >> Refresh Local Cache
or use shortcut:
CTRL + SHIFT + R
I always forget that it's there.

You may need to refresh SSMS: if raw SQL works.
Frankly, the easiest way is to close object explorer on the server and re-open. The SQL Server client tools have a problem with caching back into the Jurassic period...

Related

SSIS Project Destination Assistant "unable to use" Existing Connection Managers

Visual Studio 2019, SSIS project.
Whenever I drop a new Destination Assistant into a Data Flow I am required to create a new Connection Manager to our SQL Server instance.
Presently, there are 4 identical Data Connections (except the index appended on the name) and none of them show up in the list of "Select connection managers." TBH this is driving me nuts. It is the same behavior for both Package and Project scoped Connection Managers.
Any ideas? Everything I see everywhere just shows the Database connection managers listed as expected - but they don't show up for me.
Don't use the assistants. Not to be flippant but I don't find that they add any value. I know whether I'm pushing/pulling from a flat file vs OLE DB so why do I want to make clicks here versus just dragging the thing I want onto my palette?
Whenever I start SSIS work on a new machine, I remove the suggested favorites of source/destination assistants and add in what I use day-in and day-out.

How to fix error "Cannot resolve column..."

I am developing Java web application what based on Spring Framework, MySQL, JPA. I have a problem when try to persistence data from HTML form to SQL database, then I try to debug and fix. I am using IntelliJ IDEA Ultimate 2017.1. I catch error:
Cannot resolve column 'product_name' This inspection controls whether
the Persistence ORM annotations are checked against configured
Datasources
This is screenshot:
How to fix it?
For those who just want to disable this check, go to
Intellij IDEA -> Preferences -> Search "Unresolved database references in annotations" and uncheck it.
(macOS Mojave and Intellij Ultimate 2019.3)
This will disable the inspection and remove all the "Cannot resolve column…" errors on the #Column annotations. Intellij will stop checking if the String column names exist in the database tables. Do it at your own risk.
Open Persistence tool windows, right click on module, then set DataSource. IntelliJ IDEA will validate source code by real SQL database.
You have to manage your data sources. I followed the steps detailed here
https://www.jetbrains.com/help/pycharm/managing-data-sources.html.
In my case, I did the following (I am using Pycharms, but I assume the process is similar for other Jetbrains IDEs):
Bring the Data sources and drivers window by going to view > tool windows > database
Click the wrench icon to configure the db connection
Configure it, and try that the connection works with Test Connection
Pycharms should now autocomplete fields in the db.
If it still doesn't work:
try restarting Pycharms.
go to options (command + ,), then search for SQL, select menu SQL Resolution Scopes, and try adding a scope by clicking +, then selecting your current project folder as path, and your db as the resolution scope
I found a TEMPORARY work around for this bug.
Please before you follow my workaround do exactly what #Benjamin Crouzier's answer suggests. THEN, go to any of the unresolved columns, right click it and they click execute. and Boom annoying warning SOLVED :)
After trying all the solutions above, I solved this by clicking Refresh in the database tool window.

Unable to resolve valid table in PhpStorm

I'm getting unable to resolve table errors appear in php files containing SQL querying valid tables.
If I Ctrl + Enter over the query, then I get expected results in the DB console, and if I expand the database in the DB explorer tab then I can see the tables.
It's not affecting code execution, but it's annoying because it catches my eye when writing code, and it masks real SQL errors.
I've tried refreshing the database connection, and I've verified that the php tab is connecting to the correct database.
In 2017.2 I had to go to
Settings > Languages & Frameworks > SQL Resolution Scopes
and add my project and database link in there to get it right again.
Try re-creating DB connection from scratch (delete existing one and create it again).
Thinking of possible reasons ... I can think of this scenario:
working with project in current stable version (currently 2016.1.x);
trying EAP build for next version (2016.2 at this moment) on this project and make some DB-related changes there (even simple syncing DB);
going back to stable version (2016.1.x) .. and because new version uses newer file format/versioning for DB-related data (cached DB structure etc) IDE may start ignoring "unknown/newer" format for such data and instead of throwing appropriate warning it just "silently" throwing "unresolved table" message.
No other ideas.
I was getting what OP was getting, and the problem was my DB Server was MariaDB and i had MySQL selected as the SQL Dialect.
See File > Settings: Languages & Frameworks > SQL Dialects.
Faulty error pollution DRIVES ME NUTS TOO!
If I start having SQL resolution issues, I will check my resolution scopes (settings -> Languages & Frameworks -> SQL Resolution Scopes).
Generally I have the most issues when my project mapping is set to 'All Data Sources' by default.
The following steps always fixes it for me:
Click the Project Mapping Dropdown
Uncheck the global 'All Data Sources' setting (required to make other selection available)
Click the drop down arrow for your Database connection
Check 'All Schemas' (Or Specific Tables)
Click OK to close the settings window
Your false resolution errors should disappear after the next parse cycle.
You aren't limited to applying the above steps to just one DB connection, you can do it for all connections in your project.
Sometimes adding a custom resolution scope will work as well, but it is hit or miss for me.
Click the plus sign (top right)
Select the file you are working on and hit 'OK'
Select the 'Resolution Scope' column
Deselect 'all data sources'
Select the specific DB resources you want
Reconnecting to the DB never works for me.
Specifying the table works well... but it can become very cumbersome as the project grows.
I have also run into an additional situation where PHPStorm would only resolve some of my queries, no matter what scope resolution settings I used. However, after I attached a console to my file, they resolved just fine.
(Search for 'Attach Console' in Help | Find Action. You can also add it to a 'Quick List' or Keymap it.)
Although this answer is specifically for phpstorm, I had this same issue in IntelliJ and none of the above fixes worked for me. I had my scope added, everything was active. I could query the database in the console window perfectly fine, and I was totally stumped.
Eventually, I noticed some text in the database panel that said 0 of 4 in tiny text. It looked like this:
Upon clicking on the 0 of 4 text, I discovered there were no schemas added to the connection, even though a default database was set upon making the connection originally. Going to that page allows you to add schemas. Be sure to either select "All schemas", "Current schema", or the specific database that you want to use with your connection.
Changed dialect to MariaDB on global and project level.
OR
To dismiss this error in PHPStorm versions before 2017 which have no SQL Resolution Scopes option:
Go to File
Go to Settings...
Go to Editor and then Inspections
In SQL chapter uncheck Unresolved reference
Click Apply and then OK
Adding database name before the table name worked in my case.
For instance, instead of writing SELECT * FROM Client, put SELECT * FROM database.Client.
I will add another answer, because for me, it was a completely different (embarrassing) cause:
I somehow forgot to add the database name in the data sources general settings (where you also set the host, user and password).
In my case, I have clicked the right button in the SQLScript and change the Dialect to "Generic SQL". It worked for me.
I solved this problem as follows:
CTRL + SHIFT + F10
new query console
Write a selection query to the database, for example:
SELECT * FROM user WHERE user_email='$email' AND user_password='$password'
Enter your code page and click on the table name in the query
ALT + ENTER
run query in console
Select the console you created
First, you need to check the Schemas tab, and make sure you've added the database.
If the unable to resolve table error stills appears, there're two options to fix this:
1.You can edit the properties of the Data Source and add the name of Database, then you can see that select * from table works well.
2.On the other hand, you can also use sql like this select * from database.table. It works for me.
By the way, in many situations, autocomplete can be very useful.
[PHPSTORM]I solved this problem by setting
Languages&Features
SQL Dialect
adding your current file into path and modify its SQL Dialect as a server you are using.
NOTICE!!!!! mine is MySQL but it is exactly MySQL causing problems, after switching into [generic SQL] PROBLEM SOLVED!!!

New LightSwitch Project

I have started a new Lightswitch project using a SQL database that was created with Lightswitch. When I publish and install the new Desktop project everything goes fine with no errors in publishing, installing or loading the new application. The first and only screen appears. I can click on different records and the data shows up and I can edit the data. However, if I use the list search function all of the fields get Red x'd.
The original application works the way it supposed to work.
I have tried with and without IIS: Published with (local) and (IIS) and get the same results with both methods.
The connecection string options for the new app are not the same as the original in that System Admin and Sytem user connecection strings are not offered so it is difficult to know if I replicating a working setup or not.
In Mananagement Studio I am awash in security, permissions, roles, and login selecitons. It seems clear that this is permission level problem but I have no idea on where to start trouble shooting.
see:
Diagnosing Problems in a Deployed 3-Tier LightSwitch Application
http://blogs.msdn.com/b/lightswitch/archive/2011/09/20/diagnosing-problems-in-a-deployed-lightswitch-application-eric-erhardt.aspx
How many string properties are in the table that you're displaying? Is there a large number of properties that don't need to be included in the search?
This forum post discusses the same issue as you're encountering: Search returns error "Unable to load data" with a Red X
Have you checked your connection string setup? I do have those issues back when I was using SQL Express on development and using SQL Server Enterprise as my target database server.

Local Load Testing: The load test results database could not be opened

I am creating some Load tests using VS2012. I can run the tests using a StorageType of "None", but when I change this to a StorageType of "Database" I get the dreaded error
The load test results database could not be opened. Check that the
load test results database specified by the connect string for your
test controller (or local machine) specifies a database that contains
the load test schema and that is currently available. For more
information, see the Visual Studio help topic 'About the Load Test
Results Store'. The connection error was: An error occurred while
attempting to create the load test results repository schema: To
create the database 'LoadTest2010' your user account must have the
either the SQL Server 'sysadmin' role or both the 'serveradmin' and
'dbcreator' roles
I have created a database on a non local copy of SQL called LoadTest. When I test the connection from the SQL Tracing Connect String dialog I get a success.
I have created a SQL user that has the Server Roles of dbcreator, public, serveradmin and sysadmin. The user has a User Mapping to the LoadTest2010 database that was created from the loadtestresultsrepository.sql in the VS2012 IDE directory. On the database the user has the Database role memberships db_accessadmin, db_datareader, db_datawriter, db_owner.
In the Owned Schemas i ticked on the db_datareader, db_datawriter, db_owner and db_securityadmin howver these have now gone to a blue square instead of a tick when displayed.
So what's going on? Is Visual studio trying to create the database or is something else the issue?
I am not using TestControllers or TestAgents I am simply using a local run.
The answer was simple. I was setting up the connection string in the "SQL Tracing Connect String" instead of clicking the little "Manage Test Controller" icon at the top of my load test window and setting up the connection string from there.
Now I'm off to remove some of those superfluous permissions I created on that SQL user :)
Edit:
The SQL Connection String is NOT stored in the loadtest files. The setting seems to be PC specific so I had to change it on the build server - in one loadtest file (address.loadtest) as shown, then all the other loadtests adopt the same connection string.
I am using Visual Studio 2013 and had this error as well, but for a different reason. It's not entirely clear when setting up a load test for the first time that it will attempt to save the results to a database by default. I didn't realize it was trying to save results to a database until I got the error on my first run attempt. Furthermore, in the load test wizard, there is no screen to configure the database settings or create the database schema for that matter.
I found this article on MSDN which helped me solve the problem.
How to: Create a Load Test Results Repository Using SQL
https://msdn.microsoft.com/en-us/library/ms182600%28v=vs.120%29.aspx?f=255&MSPPError=-2147217396
Basically, it explains that you first need to run a script to create the load test repository schema. Once this is in place on your SQL instance is (it could be anywhere you like), then you can point your load test to this database and save your results there.
For me after I had set database connections and all the test results was still not writing to the database.
I forgot to change my storage type in the properties section of the runsettings.
The property is called 'Storage Type'
Storage Type : change it from None to Database