Living document for replication of SQL Server Tables - sql-server-2005

I've been tasked to create an internal site for my company to document the replication of tables in our databases. I'd like to make the site dynamic, but to do this I'd need to query sql server to figure out how each table replicates. I know you can query sql server to figure out things like column names and many other features, can you query sql server to determine how a table replicates, and if so is there a good document to show me how or get me started? We're running sql server 2005 and c# or tsql are the preferred languages for me to use for this.

Try taking a look at the documentation for the syspublications and syssubscriptions system views in the Distribution database. Does that provide you with the information you need to build your site? If not, what else are you looking for? I've included links to the documentation for those views below.
syspublications
syssubscriptions

Related

Identify relationships between multiple databases in SQL

I am working on migrating an application from one server to the other. According to the connection string of this application, it is touching different databases. Meaning a view query in DB1 will touch a table in DB2. So while migrating this application, I constant get to see chain of 'Database unavailable' errors and every time I see such error, I have to migrate that specific database.
I am wondering, since we have ER diagrams to know about relationships between tables in a database, is there any way in SQL server to know the relationships/linkages between different DATABASES in a server? Are there any tool that does this?
Depending on number of databases you have, here would be a somehow quick way you can find that out (number of required search = number of available databases in the server):
Use 'SQL Search' application of Red-get
(https://www.red-gate.com/dynamic/products/sql-development/sql-search/download)
and search for the other database names one after another by selecting
your database of interest. Select all objects.
If you have metadata oriented design (a Stored Procedure looping through the names of different other Stored Procedures / Functions from different databases which are stored in a table as metadata and executing them with a wrapper Stored Procesure), then you will have make use of SQL Locator software (http://www.sqllocator.com/Downloads.html) to search for database names in SQL Table values.
Both of the above software are free.
You need to have SSMS (SQL Server Management Studio) installed to be able to use this application. After installation, ‘SQL Search’ will be directly available in your SSMS as an add-on.
SQL Locator can be directly used by providing the SQL Server name and your SQL Server credential.
Note:- The above steps will help you find out the referenced databases from a certain database within the same SQL Server. If you need to find out databases from Linked Server (I do not believe your question is asking that anyways), then you will have to smartly utilize the same above tools to find the external server reference by searching the external server name.

is a generic query for verifying and fixing table possible?

Is it possible to build a generic query that verifies and if needed corrects a whole table schema?
Example:
On my dev machine i have a sql server with some tables. I, and others, make changes to the tables and sometimes misses to notify the others about them. :/
I want to build a query that reads the dev sql tables and creates a query that i can run one another sql server and updates that table there so that they are equal.
I cant drop the table and recreate it unfortunately. I dont want to change any of the data.
If this is to hard with sql syntax is there some tools that can do this for me? The sql tables are almost always on different machines and most likely i cant connect directly to them from the same place. So tha fixing/verifying needs to be done "offline".
Time is not of the essence, it can be a very slow query as long as it works.
update: I want to verify the sql schema and not the content of the table
update2: We are using SQL Server 2008 R2
It is possible, but not easy. This kind of tool is called a Data Dictionary, and you can write one yourself (see advice from the Database Programmer) or you can buy a commercial one, for example RedGate's SQL Compare.

Find difference between a table on many server

On my work we have a database on our server. But for some clients we implement on ther server the database. The problem comes when We change a table design on our server. We need to replicate that change manually on every client server.
Is there a way to see the difference of a table or all tables to know what tables or store procedures needs to be updated.
Here is a post on stackoverflow with list of tools to do a Schema compare: What is a free tool to compare two SQL Server Databases?
Additionally if you have VS 2010 Premium or Ultimate you can do a schema compare : http://msdn.microsoft.com/en-us/library/dd193250%28v=vs.100%29.aspx

SQL partitioning on non-enterprise server?

I tried using partition function on my SQL server to partition one of my large table but I got an error saying "Partition function can only be created in Enterprise edition of SQL Server. Only Enterprise edition of SQL Server supports partitioning." So I was wondering how does everyone else that doesn't have Enterprise version solve this?
Any advice would be great!
The method Oleg Dok is referring to is called a "partitioned view". Microsoft has covered it extensively in the SQL 2000 and 2005 docs. Just Google the term and you'll get lots of advice.
Basically, if you have N tables with identical schemas, you can create a view on top of them that UNIONs them together and exposes a consolidated view of your data. There is a fairly good blog post describing this. You'll hit some hiccups, especially around performance, so choose indexes wisely, keep the stats updated, and make sure to query on them properly.
You may develop your own partitioning. The simplest is: several tables and one view to access them. And unified process of modifying the data. There will be some pitfalls like uniquefier of rows in several tables (distributed PRIMARY KEY) and many more.

show relationships like Access

Is there a way to show table relationships as can be done in Access? Consider two tables:
Services
serviceid
application id
Application
application id
application name
I have already set up the diagram.
When opening the table service id I want to see the related application details like in Access.
Is this possible?
First of all, you an always use access to connect to SQL Server and see relationships through it.
The built in database diagram feature will also show relationships, as you describe. You can find it under the database in question in the diagrams node.
Here is an article about different options to produce an ERD.
Update:
In order to see results, I would suggest using access to connect to SQL Server, as described in the link above.
The SQL Server GUI does not have this facility, and if you want to see results from several tables you need to write the SQL queries that will generate the wanted data.
You could also create a VIEW:
CREATE VIEW ServicesApplication AS
SELECT S.ServiceID, S.ApplicationID, A.ApplicationName
FROM Services AS S
LEFT JOIN Applications AS A
ON S.ApplicationID = A.ApplicationID
That way you can always access the coupled data easily by manipulating the ServicesApplication view instead of the separate tables.
SQL 2008 doesn't have anything built in to provide that functionality. Almost sounds like you're looking to trouble shoot an application by looking at database entries...if thats true I'd recommend learning tsql well enough to write these statements as you need and not rely on another application to provide a visual interface. heh, if I'm completely wrong with that, ignore me :)
If you still want the 3rd party application route...I beleive TOAD has that functionality within it, though I've never connected it to a MS SQL 2008 server before. There are other third party applications out there that will provide this functionality, though I imagine they aren't all free. If you're looking for a free solution and already have Access going, Oded probably has the best idea here...connect MS access to the SQL 2008 server (linked tables) and use MS access to provide the features you want from ms access :)