Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Microsoft SQL Server > Re: copying dat...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 10 Topic 10986 of 11517
Post > Topic >>

Re: copying data from one server to another

by imorxr@[EMAIL PROTECTED] May 14, 2008 at 09:52 PM

On Apr 22, 8:49 pm, "Plamen Ratchev" <Pla...@[EMAIL PROTECTED]
> wrote:
> You can add linked server and use it to copy the table data across
server.
> Creating linked server is done using sp_addlinkedserver:
>
> EXEC sp_addlinkedserver 'RemoteServer', N'SQL Server'
>
> Based on security settings you may need to map remote server logins.
This is
> done using sp_addlinkedsrvlogin:
>
> EXEC sp_addlinkedsrvlogin 'RemoteServer', 'false', 'LocalUser',
> 'RemoteUser', 'RemotePassword'
>
> Then you just run a normal query referencing the linked server table
with 4
> part name:
>
> INSERT INTO TargetTable
> SELECT <columns>
> FROM RemoteServer.RemoteDB.dbo.RemoteTable
>
> HTH,
>
> Plamen Ratchevhttp://www.SQLStudio.com



How if i need to : 'SET IDENTITY_INSERT ON' before execute insert
command ?

i have try it before :
SET IDENTITY_INSERT [remoteservername].Library2005.dbo.tblLanguages ON
--> will result error
[remoteservername].Library2005.dbo.sp_executesql N'SET IDENTITY_INSERT
dbo.tblLanguages ON' --> no error

That command executes without error, but the problem is that I cannot
perform the actual insert, because it is not within the execute
statement. In other words, the following doesn't work:

EXECUTE [remoteservername].Library2005.dbo.sp_executesql N'SET
IDENTITY_INSERT dbo.tblLanguages ON'
INSERT INTO [remoteservername].Library2005.dbo.tblLanguages
(colLangID, colEnglish, colGerman, colSpanish)
SELECT colLangID, colEnglish, colGerman, colSpanish FROM tblLanguages

This results in the error:

Msg 7344, Level 16, State 1, Line 2
OLE DB provider 'SQLOLEDB' could not INSERT INTO table
'[remoteservername].[Library2005].[dbo].[tblLanguages]' because of
column 'colLangID'. The user did not have permission to write to the
column.

The remote server is linked correctly on my end via the
sp_addlinkedserver and sp_addlinkedsrvlogin. Is there any way to force
the remote server to turn IDENTITY_INSERT ON permanently and then let
me execute as many INSERTS as I want and then turn it back OFF?
 




 10 Posts in Topic:
copying data from one server to another
Guineapig1980@[EMAIL PROT  2008-04-22 06:11:12 
Re: copying data from one server to another
"Plamen Ratchev"  2008-04-22 09:49:52 
Re: copying data from one server to another
imorxr@[EMAIL PROTECTED]   2008-05-14 21:52:28 
Re: copying data from one server to another
"Plamen Ratchev"  2008-05-15 01:40:33 
Re: copying data from one server to another
Erland Sommarskog <esq  2008-05-16 20:04:24 
Re: copying data from one server to another
imorxr@[EMAIL PROTECTED]   2008-05-14 23:18:58 
Re: copying data from one server to another
imorxr@[EMAIL PROTECTED]   2008-05-14 23:25:58 
Re: copying data from one server to another
imorxr@[EMAIL PROTECTED]   2008-05-15 01:35:39 
Re: copying data from one server to another
"Plamen Ratchev"  2008-05-15 09:01:18 
Re: copying data from one server to another
imorxr@[EMAIL PROTECTED]   2008-05-15 20:06:59 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Dec 3 1:19:08 CST 2008.