Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting data with Linked Servers

Status
Not open for further replies.

Dimitrie1

Programmer
Jan 5, 2007
138
CA
I have an asp.net app and am calling stored procedures. My app worked great until I had to use linked servers. I did some research and learned that yes performance is impacted and specially on inserts. i read about openquery but can't figure out how to use openquery with my current sql statement - please help.

Code:
 select @current_licence = f.folderrsn 
from amandaosg.amanda_dev.dbo.folderpeople fp join amandaosg.amanda_dev.dbo.folder f 
	on fp.folderrsn = f.folderrsn
	where fp.peoplersn = @ArgRegistrationPeopleRSN
	and f.foldertype =    @FolderType and f.subcode = @subcode and statuscode = 2 and folderyear = convert(numeric,substring( convert (char(4),datepart(yy,@now)),3,4) )


 
Since it is only referring to one server why not create a stored proc onthat server and execute it?

Also get rid of that convert(numeric,substring( convert (char(4),datepart(yy,@now)),3,4) ) in your statment, it has to repeat for evey single row in the select. Since they all refer to the same varaible, create another variable to store the converted value and use that instead.

"NOTHING is more important in a database than integrity." ESquared
 
my connection is only to server1 and this database is on server2.

it's an internet app and the security guys won't let server2 thru the firewall

good point on the convert.... statement - I stole this proc from somebody else.

 
What SQL Sister was saying was create a stored procedure on Server2, and have Server1 execute the procedure on Server2 via the linked server.

You'll need to enable RPC and RPC Out on the linked server before you can do this.

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

My Blog
 
oh ok missed that - sorry sqlsister.

I tried that and it worked great. thanks mrdenny/sqlsister
 
No problem.

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

My Blog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top