Websphere v4 Microsoft SQL Server JDBC Driver want to include SQL Synonyms - sql-server

My current database contains synonyms. The driver is currently getting only the tables. I have searched many documentations and haven't found some workaround for this.
Do you have any idea how I could include the synonyms in the driver?

This is not a driver issue. Synonyms don't appear in the sys.tables or information_schema.tables catalog views. So most metadata scanning tools can't identify them as thing-that-can-be-queried.
This is made harder because you can have synonyms for tables, view, procedures, etc. And the metadata associated with the synonym is just the name of the target object as it was specified in the CREATE SYNONYM statement.
So if you can provide a SQL query directly to the tool, synonyms will work. But don't expect to pick a synonym from a list of tables.

Related

Is it possible to create table/views under a package in the schema?

In MS SQL Server 2012/oracle, I need to create something like a.b.c
where c is the table/view name, b is the package name and a is the
schema name.
I wanted to create a table/view in two levels. I couldn't find any
proper document regarding this. Any suggestion to find the good document
will be helpful.
MS SQL Server and Oracle are very different. They're both relational DBs, but different vendors and don't function quite the same. There are similarities though.
At any rate, you don't create tables under a package. A table is an object much like a package is an object. A package is designed to hold a collection of procedures/functions within Oracle. SQL Server doesn't even implement packages.
So, as an Oracle example, the best you're going to get is Database > account (or schema..) > table.

SSMS how to find entity in database

I have been told an entity called table_loader in a database, database_1 in SSMS (version 2008 R2) exists and needs to be fixed. It is not obviously a stored proc. It's purpose is to convert an excel spreadsheet to table data. Is there any easy way to search a database for an entity name in SSMS.
The find function appears to work only with text SQL files as opened in SSMS.
Since originally posting I have found out from a colleague that this entity is a DTS package; however, I believe searching a database for a name is still a useful thing to be able to do, especially if you don't know what "layer" the entity is in with respect to the database folder structure.
Thanks.
A great, free, tool is Red-Gate SQL Search. It lets you search for just about any object from SSMS in a very user-friendly manner. http://www.red-gate.com/products/sql-development/sql-search/. You just type in the object name and it will search across databases and object types and display what it finds. I like it because it also searches within sproc text and such which can be very helpful, depending on what you're looking for.
If you open up a query window in SSMS you can use the below SQL to do a wildcard search:
USE [dbname]
SELECT * FROM sysobjects WHERE name like '%table_loader%'
This thread has got some good queries and lists the xtype meanings (sproc, table, key etc):
How do I get list of all tables in a database using TSQL?

Printing Schemas in Microsoft SQL Server Management Studio

I'm on microsoft sql server management studio 2008 10.0.1600.22
I have a number of databases (the things that have a can icon in Object Explorer), Each of these Databases contains several folders with generic dames like; Databases, Security, Server Objects, Replication, Management, and lastly SQL Server Agent. Inside the "Databases" folder, there are a large number of databases which each have their own columns/rows etc...
So for example
BLOCK1 (SQL Server ##.#.####)
[-]Databases
.[+]System Databases
.[+]Database Snapshots
.[-]GROUP1
..[+]Database Diagrams
..[-]Tables
...[+]System Tables
...[+]dbo.Table1
...[+]dbo.Table2
...[+]...
...[+]dbo.TableN
.[-]GROUP2
..[+]Database Diagrams
..[-]Tables
...[+]System Tables
...[+]dbo.Table1
...[+]dbo.Table2
...[+]...
...[+]dbo.TableN
...
.[-]GROUPN
Is there any high level built-in command or utility I can use to print out the schema for each entire 'Block'?
I want a directory or 'map' of some sort I can use to see what Tables are within each Databases within each block. Expanding each database to see the contained tables often causes Microsoft SQL Server Management Studio to freeze so having a printed secondary 'map' would be very useful in figuring out where things need to be done in a relatively LARGE network where finding out table names can take a very long time (loading/crash/freeze) or be functionally untenable.
I don't need column names; I can query the table to get that; I just need an easy way to see all the table names quickly to navigate and target queries. This is for work purposes; This RDBMs is extremely large and queries function fine against it; but expanding it to see where to target queries is impractical in object explorer due the extremely large number of components which clicking the [+] next to a database name is more likely to crash SQL server than return useful information if not taking a minute or so to load all the table names.
I know the simple but time consuming way to get this information; I'm just wondering if MS SQL Mgmt Studio 2008 might happen to have some built in function to just generate this list in plain text so I can print it out?
There are several "Object Catalog Views" in SQL Server that contain the names and types for the system objects (as well as other info). The one you may be most interested in is sys.objects, although there are others (sys.tables, sys.columns, etc.).
Here is a very generic example query:
use AdventureWorks2008
go
select *
from sys.objects as o
order by o.type
For more info, see the documentation.
nvm just did it by looping
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES (nolock)
WHERE TABLE_TYPE = 'BASE TABLE'
order by TABLE_NAME asc
and putting it in charts. this is more an issue of finding a better file format to store it in because the excel schema is 175MB large and would be 313k+ pages if physically printed. This initiative needs to re-examined from another angle. question closed

Get SQL Server schema via a SQL query?

I've inherited a clunky and horribly un-documented site from a bad developer and am trying to get a look at the database schema. Unfortunately the web host is the worst I've ever dealt with and has no control panel capability for viewing the db schema or even exporting tables.
Is there any way that I can get a look at the schema via a SQL query (this would be with ASP + SQL Server)? My end goal here is to see what tables exist, possibly get a SQL dump of the vital tables, and then recreate the whole thing the right way.
The INFORMATION_SCHEMA schema is a good place to start:
SELECT * FROM INFORMATION_SCHEMA.TABLES
SELECT * FROM INFORMATION_SCHEMA.VIEWS
...and so on.
You might also want to have a look at using SMO, an API to get at the metadata in SQL Server.
I'm not sure if simple queries like
SHOW TABLES;
DESCRIBE table_name;
SHOW TABLE STATUS from table_name;
are valid in MS SQL. They would also be useful
SchemaSpy http://schemaspy.sourceforge.net/ is a great tool for analyzing existing databases. It generates html lists of table and constraints as well as a graphical representation of relationships

SQL Command for generating schema text (similar to CreateTo or AlterTo)

SQL Server 2005. Is there a sql query that will return a text field containing the same type of schema info as you would find in doing a right click table -> Script Table As -> Create To (or Alter To) from SQL Server Management Studio ?
I'm looking for a single/flat format that describes the entire table, including constraints, indices, etc.
I am aware of:
sp_help table_name
but that doesn't provide the single flat format I'm looking for. Ideally it would be in a scriptable format, such as the AlterTo result that could be executed against the server.
This is for a scheduled process that documents table schemas on a nightly basis for checking in to version control (SVN).
Not really. A table def is a collection of columns, constraints etc.
There is an SVN plugin that may help called ScriptDB4SVN. I've not used it personally, I'm going on hearsay.
Was searching the 'net again for an answer to this, and came across this SO question. It doesn't accurately capture all the same data as SQL Management Studios Create-to, but enough for my purposes (scripting the database structure for version control purposes).
There is no such command in SQL Server. This is primarily because the Scripting facilitiy is actually in SMO and not in SQL Server itself. There are a number of free console command-line tools that can do it that you could call via xp_CmdShell.
However, if you really want to do this from T-SQL, then you will need a script or stored procedure that enumerates all of the tables attributes, columns, column datatypes, defaults, nullabilty, etc. etc. and then reassembles it into a CREATE TABLE script. This is a Huge task. That's the bad news. The good news is that someone (Lowell Izaguirre) has already done this and posted it in this article (http://www.sqlservercentral.com/scripts/Miscellaneous/30730/) at SQLServerCentral.Com.
Enjoy.
Not really - you can either use C# (or VB.NET) and SMO (SQL Management Objects) to script out your database objects (tables and all), or you can use SQL to get the list of columns for a table:
SELECT * FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Your Table Name here'
But I don't know of any easy way in SQL itself to create Create/Alter scripts for database objects, sorry.
Marc

Resources