Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9281453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:07:31+00:00 2026-06-18T18:07:31+00:00

I have created ASP.NET C# Web Application (with Database as SQL Server 2008 ).

  • 0

I have created ASP.NET C# Web Application (with Database as SQL Server 2008). My Application Connects to Different databases (Say Count is 10). they all are have same structures i.e. Same Table Name,Stored Procedure Name,SP Argument Count & Type,Table Schema all are same.

But data inside is different.

I have stored procedure inside every database dbo.usp_getData1 which accepts some parameters do some table scans and retrieve data with respect to only that database.

My Question is How Can i Retrieve Data from all my Database using only one of the stored Procedure (As Parameters/Table Structure is same) ?

I can achieve same either by SQL Server or C# Coding.

Views will be helpful for me ?

CREATE VIEW [ schema_name . ] view_name [ (column [ ,...n ] ) ] 
[ WITH <view_attribute> [ ,...n ] ] 
AS select_statement 
[ WITH CHECK OPTION ] [ ; ]

<view_attribute> ::= 
{
    [ ENCRYPTION ]
    [ SCHEMABINDING ]
    [ VIEW_METADATA ]     } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T18:07:33+00:00Added an answer on June 18, 2026 at 6:07 pm

    You can select from multiple databases (on the same server) if you fully qualify the table name like Database.Schema.Table.

    See e.g.
    http://www.sqlteam.com/article/selecting-data-from-different-databases

    If you want to pass the database names as a parameter to your stored procedure, you’ll probably have to resort to dynamic SQL, although this could potentially open a whole new can of worms.

    See e.g.
    SQL 2000 Table Name as variable in stored procedure and
    http://www.sommarskog.se/dynamic_sql.html

    Simple example:

    CREATE PROCEDURE SelectEverything
        @tableName NVARCHAR(250)
    AS
    BEGIN
        DECLARE @sql NVARCHAR(500)
        SET @sql = 'SELECT * FROM ' + @tableName;
        EXEC(@sql);
    END
    GO
    

    If you execute this proc:

    EXEC dbo.SelectEverything 'SomeOtherDatabase.dbo.SomeTable'
    

    It will select everything of table SomeTable in schema dbo of database SomeOtherDatabase.

    But please read the link about dynamic SQL.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application implemented in ASP.NET MVC3 and SQL Server 2008 Express.
I am deploying an ASP.NET application and SQL Server (2008) database on a live
I have the following scenario. I have created an ASP.NET web application (framework 3.5)
I have created blank Asp.Net-MVC 3 web application and want to write my own
I have created a Visual Studio 2010 ASP.NET Web Application. With it I have
I have created a Visual Studio 2010 ASP.NET Web Application. I've noticed that if
I have already created my application on web socket with ASP.net 4.0. I just
I have a web application in Asp.Net. I've created my master page and inside
Background information Let's say I have two database servers, both SQL Server 2008. One
I am trying to deploy my ASP.NET website with database (SQL Server 2008) on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.