Hello
how do I insert to an other db using a insert-statement?
INSERT INTO OtherDBsTable(Something)
SELECT Something FROM ThisDBsTable
TIA
/LasseINSERT INTO SomeDatabase.TheTableOwner.TheTableName (column, list,
separated, by, commas)
SELECT column, list, separated, by, commas FROM
SomeOtherDatabase.TheTableOwner.SomeTableName
Keith
"Lasse Edsvik" <lasse@.nospam.com> wrote in message
news:Onl6Qq7LFHA.3616@.TK2MSFTNGP09.phx.gbl...
> Hello
> how do I insert to an other db using a insert-statement?
> INSERT INTO OtherDBsTable(Something)
> SELECT Something FROM ThisDBsTable
> TIA
> /Lasse
>|||INSERT INTO OtherDBsTable(Something)
SELECT Something FROM otherDBName.dbo.ThisDBsTable
"Lasse Edsvik" <lasse@.nospam.com> wrote in message
news:Onl6Qq7LFHA.3616@.TK2MSFTNGP09.phx.gbl...
> Hello
> how do I insert to an other db using a insert-statement?
> INSERT INTO OtherDBsTable(Something)
> SELECT Something FROM ThisDBsTable
> TIA
> /Lasse
>|||Use databasename.owner.tablename
Example:
use northwind
go
create table pubs.dbo.t (
colA int
)
go
insert into pubs.dbo.t (colA)
select top 1 orderid from dbo.orders
select * from pubs.dbo.t
go
drop table pubs.dbo.t
go
AMB
"Lasse Edsvik" wrote:
> Hello
> how do I insert to an other db using a insert-statement?
> INSERT INTO OtherDBsTable(Something)
> SELECT Something FROM ThisDBsTable
> TIA
> /Lasse
>
>|||"Keith Kratochvil" <sqlguy.back2u@.comcast.net> wrote in message
news:%23p2j5s7LFHA.3064@.TK2MSFTNGP12.phx.gbl...
> INSERT INTO SomeDatabase.TheTableOwner.TheTableName (column, list,
> separated, by, commas)
> SELECT column, list, separated, by, commas FROM
> SomeOtherDatabase.TheTableOwner.SomeTableName
> --
> ThisNewsGroup.AGuyCalledKeith
>
Your sig corrected Keith...|||Hi Lasse,
And don't forget the fact if you want do the same between different machines
and db, add the link between them.
Have a good day,
"Alejandro Mesa" wrote:
> Use databasename.owner.tablename
> Example:
> use northwind
> go
> create table pubs.dbo.t (
> colA int
> )
> go
> insert into pubs.dbo.t (colA)
> select top 1 orderid from dbo.orders
> select * from pubs.dbo.t
> go
> drop table pubs.dbo.t
> go
>
> AMB
> "Lasse Edsvik" wrote:
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment