Use dbo.table SQL Server error - sql

I have a database, and I am importing a big table...
When I try to execute a stored procedure I have no success, to check I do something simple like:
select * from tableAT;
but the tableAT is marked as error (even when it appears in the Object explorer window),
Msg 208, Level 16, State 1, Line 1
Invalid object name 'tableAT'.
but if I do right click and select the icon of the table and select
SELECT TOP 1000 ROWS
a result is coming and the query shown is
SELECT TOP 1000 [1]
,[2], etc...
FROM [DB_NAME].[dbo].[tableAT]
if I change the way I am calling the store procedure to
exec procedureA [DB_NAME].[dbo].[tableAT]
I get error as if the table does not exist?
Do you know why could this be error?
A size issue, I already incremented the database initial size files...

You must be logged in as admin user to select from this table. Because it is created for dbo. Or you should have proper rights

Make sure you've set up your table valued parameter correctly: here's an example.

Related

SQL server Invalid object name 'TableName' SSMS , Table in system

I am working on SQL Server Management Studio. I wish to open a table that is already in SSMS. I am getting below error. The table is reflecting in my tables.
Database: Consumer Complaints contains 2 tables: dbo.Consumer_Complaints and dbo.RAW P9-ConsumerComplaints.
I am trying to open dbo.Consumer_Complaints table.
Msg 208, Level 16, State 1, Line 1
Invalid object name 'dbo.Consumer_Complaints'.
Completion time: 2020-04-22T10:17:50.5134070+05:30
Steps tried so far:
CTR + SHIFT + R in the query window
Also I went to Edit -> Intellisense -> Refresh local cache after putting curser in the query window. Still no result
EDIT: after comments
SELECT * FROM [Consumer Complaints] this also has error
Msg 208, Level 16, State 1, Line 1 Invalid object name 'Consumer
Complaints
You try to execute query over "Master" database. You can change current database on the UI
or add SQL query:
USE 'Consumer Cmplaints'
You can first select the database name :
use [Consumer Complaints]
select * from dbo.Consumer_Complaints
However, you can also run the select statement with this :
select *
from [Consumer Complaints].dbo.Consumer_Complaints
Te to run
Use [Consumer Complaints]
before your select statement so as to let smss know which database scheme to use

Execution from the statement select * into return error

Can somebody help me?
I am try execute the command below in Oracle 11 and I get this error:
SQL Error [905] [42000]: ORA-00905: keyword not found.
Code:
SELECT *
INTO SAJ.ETMP_TESTE
FROM SAJ.ESAJOBJETO O
WHERE CDOBJETO = 'P800000000J03'
I read the Oracle docs and haven't found any obvious error in my statement.
https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/selectinto_statement.htm
My objective is to create the table ETMP_TESTE with structure from ESAJOBJETO.
I checked user permission and user has permission to action.
You need create table and not select into for create a table based on the result of a query
CREATE TABLE SAJ.ETMP_TESTE
AS SELECT *
FROM SAJ.ESAJOBJETO O
WHERE CDOBJETO = 'P800000000J03'
This will create an empty table named ETMP_TESTE, with the structure of the SAJ.EASJOBJETO table.
CREATE TABLE ETMP_TESTE AS
SELECT *
FROM SAJ.EASJOBJETO
WHERE 1 = 0;
This does not handle contraints and primary keys and things like that, but it will get you the table structure. The 1 = 0 makes sure no data is copied.
If you need primary keys and the like, look into extracting the DDL for EASJOBJETO. Most SQL IDEs have that functionality built in. You can edit it to correct the table name and run the script and get everything.

SQL Server 2012 - Conversion Fails for No Possible Reason with Views

I have a view setup as
CREATE VIEW dbo.my_data_view
AS
SELECT * from dbo.my_used_data (NOLOCK)
UNION
SELECT * from dbo.my_unused_data (NOLOCK)
go
I currently don't have anything in my_unused_data table. But I expect any query made to work just fine. the following is my query:
select * from my_data_view where code = '5E7230893312001084789839'
The query is failing with the message:
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value '8E2230893319020101078983' to data type int.
This doesn't make any sense. my_used_data and my_unused_data tables have the identical schema and types so nothing can go wrong there. What I have found out is that when I have data in my_unused_data. It works fine;Otherwise it fails. Is it something special with the views or what?
Problem solved, the order of the columns where swapped for column no. 3 and 4 for my_unused_data that messed things up. I didn't realise that SQL server assumes that ordering of the column is correct when dealing with SELECT * UNION SELECT * queries

select statements in oracle with for read only

I have a Database Links in Oracle, and when I query some data like: select * from kfilwrk#something for read only, I have an error: "missing keyword". I can just write select statement, but the problem is, I need to add for read only because my select statement may change some data.
UPD: when I write simple select statement and retrieve data, after that I close SQL Developer, it asks me to rollback or commit data. It means the select cursor updates some data
The syntax is WITH READ ONLY, not FOR READ ONLY and it can only be used with sub queries:
SQL> CREATE DATABASE LINK MyLink CONNECT TO HR IDENTIFIED BY HR USING 'sampleHost:1521/XE';
SQL> SELECT COUNT(*) FROM (SELECT * FROM Dual#MyLink WITH READ ONLY);
COUNT(*)
----------
1
See also http://docs.oracle.com/database/121/SQLRF/statements_10002.htm#SQLRF55295:
subquery_restriction_clause The subquery_restriction_clause lets you restrict the subquery in one of the following ways:
WITH READ ONLY Specify WITH READ ONLY to indicate that the table or view cannot be updated.
Alternatively, you can set your transaction into read only mode:
SET TRANSACTION READ ONLY; -- Read only
...
SET TRANSACTION ISOLATION LEVEL READ COMMITTED; -- back to default (read committed)
If you query over a DB_LINK the database assumes there are transactions to COMMIT on close.
Also, SQL Developer has a shared connection for the Worksheet and the Database Navigator/Object Editors. So if you had opened a table and changed a record - that's on the same connection as your SELECT query on the worksheet.

Can a fake table be created in SQL Server 2005

I would like to know if it is possible to create a fake table in SQL Server 2005.
Because when I tried I got an error
Msg 208, Level 16, State 1, Line 1
Invalid object name 'dual'.
This is what I tried
and it did not work. For test purpose I have created a test table to execute the query.
In SQL Server you are allowed to leave out the FROM clause. So you don't need a fake table.
Instead of writing
select 42
from dual;
just write
select 42;