Given two databases named: SourceDB and TargetDB
SourceDB has a table SourceTable
TargetDB has a table TargetTable
The tables have some compatible columns you want to copy.
try this:
Code Snippet
USE SourceDB -- not needed if already in the source database's context
INSERT INTO TargetDB.dbo.TargetTable (ColumnID, SomeColumn1, SomeColumn2)
SELECT ColumnID, SomeColumn1, SomeColumn2
FROM SourceTable
I figure it might be possible to use SELECT * but if the number of columns don't match, I got an error. It was easy enough to explicitly specify what I wanted.
It's quite possible the schema 'dbo' doesn't work in all circumstances, but I figure if people are asking (like I was), we must be fairly novice and haven't set up complex databases, yet. (Hope this helps).
http://www.windows-tech.info/15/4a5e7d5023925d33.php
http://www.windows-tech.info
This is best blog for software engineer can learn c, c++,Java,c# javascript ,vb script and sql query. All are basics for web application and applet
Thursday, November 5, 2009
Tuesday, October 13, 2009
sql query for deleting duplicate rows or records in sql query
Sql query for removing duplicate records or rows from table in sql query.
WITH
Test AS (SELECT ROW_NUMBER () OVER ( PARTITION BY website ORDER BY website) AS A FROM tbladdwebsite ) delete FROM Test WHERE A > 1
Subscribe to:
Posts (Atom)