using SQL server 2014 I am able to select without specifying the schema name when it is NOT DBO.
We are now switching over to SQL 2016 and I am no longer able to select without adding the schema name?
Problem: Going back into each stored proc to add the schema name in would take a lot of time so I was wondering if it is possible to ignore the schema name somehow? I have been searching google but haven't found anything..
The procs are used in our SSRS reports, which there are over 100 and some are embedded into the reports so if there is a way to avoid having to change each one that would be great!
It seems the default schema is a property of the connecting user. Maybe you should check how the new "migrated" user has been defined.
Related
unfortunately i create table call 'sysmessages' in SQL Server 2008. when i restore the DB to SQL Server 2012 i realize that i have two Tables call 'sysmessages'.
i don't want to change my table name because it using in the code.
can i remove only from specific database system table?
it is not a table, but a view
of course you cannot remove it, but you don't need to. It is in a different schema. You will not address it like select * from sys.sysmessages, you will address it like select * from dbo.sysmessages
"i don't want to change my table name because it is used in the code" - you can/should change the code as well :)
edit - no. 2. is not applicable in SQL 2012, however it is tested and working in SQL 2008R2
You cant drop system tables,your best bet is to change your code
Ok so I have a little problem...
In my project we have a Oracle SQL Server. In the database I have access to some of an other users tables:
Tables:
|-bla
|-bla
Users:
|-otherUser (let's just call him that)
|-Tables:
|-aTable
In Oracle, to access the aTable table I use SELECT * FROM otherUser.aTable
Now, we also have a MS SQL CE database to which I sync the data from the OracleDB using the MS Sync f/w. And in the CE db - after sync - I get a table otherUser.aTable. This sounds good, so even though the CE doesn't have the User concept it just adds the same table.
BUT the problem is that when calling the same SQL query on CE as on Oracle I get a The table name is not valid error. Instead if I want to get the content of the table, the two ways that I have found to work is surrounding the otherUser.aTable with either [] or "".
However neither of them seem to work with Oracle. The [] seem to be an illegal name, and the "" seem to search for a table called just that (not an other user).
So why don't I just use the one way on Oracle and the other on CE? well I also use NHibernate as a ORM and it kind of needs the same table name for both the databases...
Is there a third way to encapsulate the table name that works with users in Oracle and just works in CE? or do you have any other ways to fix this issue?
I have no experience with MS SQL, but it seems like a problem that might be solved with synonyms on Oracle side.
Try to create synonym "otherUser.aTable" for otherUser.aTable in Oracle.
We are migrating a database from SQL Server 2000 to SQL Server 2008 R2 and have run into a problem with our schemas. In SQL Server 2000, if you didn't prefix your object names with a owner/schema (e.g. SELECT * FROM blah rather than dbo.blah) SQL Server would still figure it out. This worked even if your object was in a non-dbo owner.
In SQL Server 2005 this was changed as described here: http://blogs.msdn.com/b/mssqlisv/archive/2007/03/23/upgrading-to-sql-server-2005-and-default-schema-setting.aspx.
I can get around a database having 2 schemas by making a user's default schema xyz instead of dbo. The problem I run into is in a database where there is a 3rd schema (abc.blah). When I make the users default xyz, they can get to dbo without a hitch but get an Invalid Object error when trying to select something from abc without a schema prefix (abc.blah works fine).
Of course, it shouldn't have been coded this way to begin with but that is a different battle. I've verified that permissions are not an issue.
I'm sure others have run into this. Has anyone found a workaround other than fixing the code?
There isn't a whole lot of magic here; fix the code.
Assuming you don't have same-named objects in both schemas, you may be able to create a slew of synonyms like:
CREATE SYNONYM xyz.foo FOR dbo.foo;
...but that is going to be as much of a mess as fixing the code.
Im creating a Stored Procedure on an 2008 SQL server.
I cant find how to retrieve the creation date of a given table in MS Access using SQL (or C# since it will be running inside a SSIS)
Besides the creation data, the time it was last modified would be also needed.
Any help?
Thanks a lot.
Might depend on the exact version of Access that created the database, but this information is found in the MSysObjects table (Access 97-2010)
EDIT2: Found a fix! I used the number of the desired schema instead of the name. Should've thought of that before, really! And i think the error messages could've been a bit better aswell. Thanks for all your time!
How can i get the names of all tables inside a database through sql inside asp classic?
The server is running windows 2008, iis7.5 and microsoft jet. I've tried all the querys i could find on the internet (and here) but none have worked.
If i add a ; to the query to run a set of querys at the same time it gives me an error because the statement isn't over at the semicolon.
The master.mdf database cannot be accessed because it's of unknown format.
The sysobjects variable apparently doesn't exist.
I am using mssql 2000 format. (.mdf)
The connection is made through classic asp with the Microsoft.Jet.OLEDB.4.0 provider and ADODB connection/recordset.
How do I get list of all tables in a database using TSQL?
Query to get the names of all tables in SQL Server 2008 Database
EDIT:
I've found two folders containing databases. One is in C:\program files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\mssql\binn\templates and contains master.mdf, mastlog.ldf, model.mdf, modellog.ldf, msdbdata.mdf and msdblog.ldf. The other one is also in the \binn\template data directory and contains master.mdf, mastlog.ldf, model.mdf, modellog.ldf, MSDBData.mdf, MSDBLog.ldf, mssqlsystemresource.ldf, mssqlsystemresource.mdf, tempdb.mdf and templog.ldf. Maybe these is of some interest?
How can i tell if i have permission? Does it give a permission denied error?
Please help! No, don't. Read the 2nd edit at the top.
USE YOUR_DATABASE
GO
SELECT *
FROM sys.Tables
GO
Have you tried the example from:
http://www.kamath.com/codelibrary/cl002_listtables.asp
I almost always use the INFORMATION_SCHEMA views:
SELECT * FROM INFORMATION_SCHEMA.TABLES
If this isn't working for you, the SQL user your site is running under may not have access to the system objects. This is actually a good thing, as giving your site access to the underlying database schema can leave you vulnerable to SQL injection.
So if you do go this route, proceed with caution.
The mdf by itself is useless: you need a database engine (a.k.a. a SQL Server instance) to "run" it. As I understand the question, this is your problem.
Then you can use sysobjects in your database: unless you have added your tables to the master database
There is no practical way to use an mdf directly: if nothing else download MSDE