.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

connect 2 different database in stored procedure over the internet

Posted By:      Posted Date: October 28, 2010    Points: 0   Category :Sql Server


i have two data base in two sql server instance and different computers and different places over the internet.

I can create a stored procedure that does a select of a table from a database of a computer, and then insert the table in another database of another computer?



after prepare and insert in the other computer, SERVER2.DATABASE2.dbo.TABLE2


its possible?


thanks in advanced

View Complete Post

More Related Resource Links

Execute SSIS package stored in Database - From Stored Procedure

Dear frnds, I am trying to execute a SSIS package that is stored in a SQL Server 2005 database Want to execute from a stored procedure in same database.  What commands/operations are necessary ? I am also having Two parameter. Regards, sajid 

Update Database Record using GridView and Stored Procedure

Hi, I am trying to update record via stored procedure, but i got error at very start point. Problem is when i click on Edit link button within the Gridview it produce error. I can populate values from database fine but its produce error when i click on edit link button. Please see the code below. *********** ASP.net GridView Code I am using *****************<asp:GridView ID="GridView1" runat="server" DataKeyNames="RollID, EmpID" AutoGenerateColumns="False" Width="700px"> <Columns> <asp:TemplateField HeaderText="ApplicationID" Visible="false"> <ItemTemplate> <asp:Label ID="AppsID" runat="server" Visible="false"><%# Eval("RollID") %>'</asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="ReleaseID" Visible="false"> <ItemTemplate> <asp:Label ID="rlsID" runat="server" Visible="false"><%# Eval("EmpID") %></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Roll Name"> <ItemTemplate> <asp:Label ID="rlsVersion" runat="server"><%# Eval("Roll_Name")%></asp:Label> </ItemTemplate> <EditI

Managing TypedDataSets when there is a change in backend Table / Stored Procedure / Database schema

Hi All, I am just curious to know if there is any easier way to synchronize the TypedDataSets with the chages made to backend Table / Stored Procedure schema.  I use Typed DataSets in my project extensively and I found them very useful and easier to code, but difficult to maintain  The difficuly I have always faced is whenever there is a change in a backend database table structure or stored procedure that is linked to any of the Typed DataSet in our project requires to recreate whole DataSet again by scrapping the old one. The backend changes will not be reflected unless and untill you recreate the whole stuff again. Is there any easier way to synchronize those typed datasets with the changes made to backend database schema or any other workaround that will not required to recreate the whole DataSet again.Hope above question makes sense. Any ideas.

Unable To Connect Database Error:Sharepoint 2007 Internet Site.

Hi Techies,  we are running 4farm Sharepoint internet site. now a days we are getting the below error very regularly. Event Viewer :The description for Event ID ( 27745 ) in Source ( Windows SharePoint Services 3 ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: #50071: Unable to connect to the database SharePoint_Config on SPPREPROD02VMDK\SPPREDPROD.  Check the database connection information and make sure that the database server is running.. Sharepoint Logs:#50071 :#50071: Unable to connect to the database SharePoint_Config on pfc-penndb-tst. Check the database connection information and make sure that the database server is running.. Please Advice . Regards, raju.  Nag: http://nagaraju-sharepoint.blogspot.com. Posting is provided with no warranties.

Need to execute ALTER DATABASE inside stored procedure


SQL 2005 Standard.

I wrote a sp that uses ALTER DATABASE instruction. When I execute sp with elevated user it works fine; when I try to execute that sp with a normal user (I alerady gave execute permission for that user) it fails with "alter database failed".

I tried to modify create proc with execute as owner but nothing changed.

How can I do ?


C# How to check prammatically if null value exists in database table (using stored procedure)?


How to programattically check if null value exists in database table (using stored procedure)?

I know it's possble in the Query Analyzer (see last SQL query batch statements)?

But how can I pass null value as parameter to the database stored procedure programattically using C#?

Although I can check for empty column (the following code passes string.Empty as parameter but how to pass null value?), I cannot check for null value in the following code snippet:

SQL Queries:

USE [master]

IF EXISTS (SELECT name FROM sys.databases WHERE name = 'ExampleDatabase')
DROP DATABASE [ExampleDatabase];

CREATE DATABASE [ExampleDatabase];

USE [ExampleDatabase];

DROP TABLE dbo.ExampleTable;

IsActive BIT,


Database Tuning Advisor, Stored Procedure with datetime parameters, syntax error


I receive these error(s) in the Tuning Log. I have several stored procedures and they all use a datetime parameter.

E000    exec <some sproc name> ''2009-01-01 00:00:00:000'',''2010-09-30 00:00:00:000'',N'',N'',NULL,NULL,NULL,NULL,NULL,NULL         1    [Microsoft][SQL Native Client][SQL Server]Incorrect syntax near '2009'.

I am using SQL 2005. Any suggestions?

Thanks, Reece

Stored procedure to do defragment entire database

Stored procedure to do defragment entire database and to keep the report in seperate table?

MS SQL Server Stored Procedure - Writing on a table in another another database


I am writing a stored procedure in a database for an app that will become part of a "shell" program that was written to accept an endless # of VB.Net apps.

The stored procedure will look at data in a table on that database, but the end result is that I want to update a table that exisits in A DIFFERENT database on the same server. I think I am referencing the table itself correctly, (databasename).dbo.(tablename). The problem is that the SQL is not performing as it does if I manually run the SQL in the database I'm trying to update.

Here is the SQL:





/****** Object: StoredProcedure [dbo].[usp_ARReport] Script Date: 10/25/2010 14:43:20 ******/



transfer data from a database to another using a stored procedure


I need to transfer data  from a database to another using a stored procedure in a C# application. I have some tables in the first database and I need to transfer data from them in others tables from the second database, not all columns but few of them.

How should I do that?


Thank you for your time!



add a stored procedure from a .sql file to a database


How can I add a stored procedure from a .sql file to a database?

I have a file that contains the procedure. It has the .sql extension. I need to upload the stored procedure into a database in a C# application.


Thank you


Connect to database over the internet...




I am using Windows 7 and did install the MySQL ODBC connector a few days ago.

What I am trying: I´d like to connect to my remote database named "database" on the server "data.base.com" with a username and a password.


My Problem is, that I don´t know how create the connection string for a DSN on a server not in my intranet.

Any hints, suggestions, etc?


With Regards,


deadlock issue on my database. how to identify which stored procedure which has to be modified.

Hi ,
I am seeing so many deadlock issues on my database captured by a 3rd party tool. Could you help me identify which stored procedure is actually causing the deadlock looking at the below log information. Let me know if you need more information.
Thanks, Jeen
<deadlock-list>  <deadlock victim="process54a7948">  <process-list>   <process id="process54a7948" taskpriority="0" logused="0" waitresource="KEY: 6:72057594044678144 (cc00f361c119)" waittime="2975" ownerId="404930267" transactionname="SELECT" lasttranstarted="2011-05-02T08:19:03.683" XDES="0x8000f940" lockMode="S" schedulerid="2" kpid="9624" status="suspended" spid="65" sbid="1" ecid="0" priority="0" trancount="0" lastbatchstarted="2011-05-02T08:19:03.653" lastbatchcompleted="2011-05-02T08:19:03.653" clientapp="Microsoft SQL Server" hostname="MyServer" hostpid="2500" loginname="India\testr" isolationlevel="read committed (2)" xactid="404930267" currentdb="6" lockTimeout="4294967295" clientoption1="673185824" clientoption2="128056">   &l

Send Email from SQL Server Express Using a CLR Stored Procedure

One of the nice things about SQL Server is the ability to send email using T-SQL. The downside is that this functionality does not exist in SQL Server Express. In this tip I will show you how to build a basic CLR stored procedure to send email messages from SQL Server Express, although this same technique could be used for any version of SQL Server.

If you have not yet built a CLR stored procedure, please refer to this tip for what needs to be done for the initial setup.

could somebody give me example how I can connect to database only once if I use many models in contr


I use in my ASP.NET MVC application repository pattern and I use in controller for example 3 models:

   namespace MvcApplication1.Controllers  
        public class HomepageController : Controller  
            private IWebsitesRepository _repository_websites = new WebsitesRepository();  
            private IFirmRepository _repository_firm = new FirmRepository();  
            private IPhotosRepository _repository_photos = new PhotosRepository();  

In WebsiteRepozitory, FirmRepository and PhotosRepository classes I have:

Database1Entities _entities = new Database1Entities();

So I have 3 connections to database ? Is it wrong ? How can I solve it ?

Inserting rows via stored procedure and under certain conditions


I'm using Dynamic Data with Entity Framework in VS2010.

Let's say my table has these fields:

PersonID (FK)
LocationID (FK)

Hypothetical scenario (it's easier for me to explain this way, so just bear with me for now)... But let's say each row in the table represents "how many items were sold by such-and-such employee at such-and-such location," where location and person are foreign keys which are referencing other tables.  Basically, there should be no more than a ONE row which has a particular combination of Person and Location.  Makes sense?

So, when inserting new rows using my Dynamic Data app, the insert form displays editable fields for Person (dropdown), Location (dropdown), and Items Sold (textbox).  How do I prevent users from inserting another row into the table containing an already-existing combination of Person and Location?   How do I displaying useful feedback to them in the event that they DO attempt to do this?

I have several thoughts about this, but since I'm new to Dynamic Data, I'm not sure which way to go.  For example:

Option 1:  Use "cascading dropdowns" approach in the insert form and only pull in the "allowed" combinations of the two dropd

Creating A Stored Procedure Which Searches Team Names



I'm have on my web page a text search box which I want users to type in there favourite football team and this will display a gridview of the teams with the replica shirts I offer.

This is where I thought about creating a stored procedure to carry out this task.

I looked online for ideas but I not found anything as yet.

If anyone done anything similar to my request please let me know.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend