Table missing in a database but query works - sql

I have a table TBLT_GLDET in my SQL Server 2008 database. When I open a new query window and select the right database and execute following query
select *
from TBLT_GLDET;
the data appears. But in the tables list the table does not appear.
Also when I try to open the table for a Crystal Report using database expert in Visual Studio, it says the table is missing in the database.
What is the reason for this?
I did following things. I double checked whether it's the right database.
I refreshed the database.

Related

Invalid object name in SSMS for table in SQL Server 2016

I created a table using an EF Core 2.1 migration and was able to populate it using EF in C#. The table shows in SSMS Object Explorer and I can execute queries against the table using "Edit top 200 rows" and "Select top 1000 rows". I tried an ad-hoc query:
use ArielOpnsDB
go
select * from ZipCodeCities
The table, ZipCodeCities, is show with the error, "Invalid object name 'ZipCodeCities'. Queries against all other tables and it shows in the creation scripts generated in SSMS.
What could be the problem and how can it be fixed?
Thank you.

Inability to run an SQL statement with a "with" statement in Excel

I am trying to run SQL through excel and I have the following SQL query within the data connection:
WITH TEST_DB as (select * from TEST_ADM.KPI_SAMPLE_TEST)
SELECT DISTINCT
BASE.YEAR_MONTH AS YEAR_MONTH
FROM TEST_DB BASE
If I try running this with SQL Developer, it will run successfully, no problems but when I try to run it in Excel, I get the message:
The query did not run, or the database table could not be opened.
Check the database server or contact your database administrator. Make sure the external database is available and hasn't been moved or reorganised, then try the operation again.
Is there some sort of limitation within Excel that prevents me from using WITH statements?
If I remove the statement and select from the table directly, it works but I need to use the WITH data table 6 times in my code and its rather long.
Oh, the database is an oracle database.

Invalid object name LocalDb Table

I'm trying to run a simple SQL query on a LocalDb database in Visual Studio 2013.
Here's the query in a file GrabWords.sql:
SELECT * FROM Words
where Words is a table in the NextGen.mdf database. When I run this, I get the error:
Invalid object name 'Words'.
For more information, I actually have two databases in the project. In the Solution explorer one is called NextGen.mdf, and the other Cards.mdf. In server explorer, the first (that I am trying to query) is called AutoGenEntities and the other is CardsDBContext.
I just want to run this query to test queries and view the database - is there another tool I should be using to do this?
Try this:
USE [your Database name]
SELECT * FROM Words
This should ensure that you are targeting the correct database.

Add exsiting query to report

My report calculates the stock of inks in my stores. I built a SQL statement in VB.NET and got the correct results. How can I display these results in my Crystal Report? Or design a report such that same results will be retrieved?
I tried to use SQL Expression builder but failed.
Usually you will link Data Tables to your report using Database Expert. Do the same in Database Expert, select the Database and you can see Add Command. Select that and click the > button. You will get a Window, write your SQL Query there and press OK.
After finishing this you can see Command in Database Fields which contains all your records got from the SQL Query as result.
In Database Manager choose Add Command and then type your SQL Statement there.

Why if I select `Open Table` for temporary global table doesn't work in SQL Server 2005?

I have an issue in Management Studio Express 2005.
If I select Open Table for a temporary global table:
Not works, the error appears:
But if I write
SELECT * FROM dbo.##tempResults
then the table content will appears.
There are any fix for this problem ?
I have SP4 for Management Studio.
There is no fix for this issue, other than:
(a) using a permanent table instead of a global ##temp table. What does the global ##temp table buy you over a permanent table? They both kill concurrency just as effectively.
(b) using Script Table As > SELECT TO > New Query Editor Window. It's a little less direct but you still don't have to type and you avoid the terrible habit of using Open Table in the first place (this places all kinds of unnecessary locks on the underlying table because you could choose to edit the data in a grid, pretending you're using Excel).
(c) moving past SQL Server 2005. In SQL Server 2008+ the menu option Open Table is gone, now there are two separate options, edit top n rows and select top n rows. The latter does (b).