How to merge tables from 2 databases in SQL Server 2008 - sql

I'm using SQL Server 2008 - just a standard edition. Sorry if this is a rather basic question, but I know very little about SQL
I have 2 databases I've previously created using Visual Studio that would now benefit from being merged. By merged I mean copying the tables from the 2nd database to the first and deleting the 2nd database.
Is there a simple way of doing this through the SQL Management Studio?

You can use OPENROWSET to read data from one database and merge it into another.
For example:
USE DBToMergeInto;
INSERT INTO TableToMergeInto
SELECT * FROM OPENROWSET
('SQLOLEDB',
'Trusted_Connection=yes;Server=192.168.1.1\ServerToMergeFrom',
'DbToMergeFrom.dbo.TableToMergeFrom')

Related

Transfer database from SQL Server 2008 version 10.50.2500 to 10.0 2531

I cannot believe this is so difficult. Backup / Restore fails. Import and Export both fail with a variety of silly errors.
Is there a way to do this that works?
Try scripting out the schema and data, with the SQL Server Management Studio
Article explaining how to use SQL Server Management Studio
If that doesn't work, you'll have to use a more advanced third party tool. Like, for instance, Red Gate's Sql Toolbelt, where:
SQL Compare allows you to compare and merge schema between 2 databases
Data Compare allows you to compare and merge data between 2 databases

How can I select data in the same query from two different servers and databases from SQL Server Management Studio?

How can I select data in the same query from two different databases that are on two different servers, one DB2 Server and the other a SQL Server?
On your sql server, set up a linked server to the db2 database.
Then write your query on sql server. I suggest that you use openquery for the db2 stuff. If you have to combine the data, populate a sql server temp table with the openquery results and work from there.
The reason I suggest this is performance. I have found that if you use this syntax
select somefields
from server.database.owner.table
where whatever
sql server will bring back the entire table from the linked server and apply the where clause afterwards.
You can set up a linked server http://support.microsoft.com/kb/222937
How to create a linked server

SQL Server 2008 cross server queries 2000

I need to create reports on SSRS 2008 from data available on SQL Server 2000, now; the database on SQL2000 is preferably not touched so I am avoiding adding stored procedures, views, indexes etc..
What would be the right solution?
What I would be needing is a place where I can put stored procedures, views etc so I can do reports.
Thanks.
create an ssis package / dataflowtask, copy your data from one source (sql 2000 - sql 2008r2)
create a reporting database, move your data to this database and make your reports on this database

SQL Server 2005 or Visual Studio 2005 - writing my first procedure, any tips or good starting points?

I'm about to write my first procedure to check if yesterdays data exists in one database, and if it select some of the data, use a count and insert that data into another database. If the data doesn't exist, then send me an email.
I'm using SQL Server 2005 and I'd like to ask the community for tips or good starting knowledge on smart procedure coding.
Thanks!
Here is an article on MSDN about stored procedures on SQL Serve 2005 that should help.

How can I transform database from sql server 2005 to 2000

how can I transform database from sql server 2005 to 2000
Use SSIS to export the database directly to SQL Server 2000.
First make sure that you aren't using any native 2005 features like included columns on indexes, XML features, etc. Then you can script the schema out using SSMS, and export the data using BCP or SSIS to SQL 2000. Some vendor tools exist like RedGate SQL Compare and Data Compare that make doing this a whole lot easier if you have primary keys defined on your tables.