English 中文(简体)
如何动态利用储存程序中的多个数据库
原标题:how to use multiple database from a stored procedure dynamically

In Sql Server 2005, I have a stored procedure, in which i have wrote some commands to create a table and add some records in it.

Create Procedure Procedure1 AS 
Begin
    create table TmpTable(CD Decimal(10,0), Descr Varchar(50));
    Insert Into TmpTable Values(0, Not Applicable );
    Insert Into TmpTable Values(1, ALL );
    Insert Into TmpTable Values(2, Selected );
    Insert Into TmpTable Values(3, Only New );
END

i 希望在所有现有数据库中设立这一表格,即不知道在我称之为这一储存程序时有多少数据库。

最佳回答

您可以尝试通过服务器的数据库清单,使用一个 cur子,然后在 cur子内使用上述代码。 页: 1 服务器通过其总数据库,每家服务器都有功能,可以要求用户获取信息。

我过去做了一些事情。

探讨这一联系,希望对你有益:

问题回答

暂无回答




相关问题
SQL Server database is not visible

I have installed ASP.NET application with database on our server. ASP.NET application created database using connection string below. The problem is that I do not see database in SQL Server Management ...

Most efficient way to store number 11.111 in SQL Server

What datatype is the most efficient to store a number such as 11.111. The numbers will have up 2 digits before the point and up to three after. Currently the column is a bigint , I am guessing that ...

表格和数据表

是否需要在提瓜表之后更新表格统计数据,还是自动更新?

Inconsistent Generate Change Script

I add a column of type tinyint and being set to not allow nulls in a table and generate the change scripts. The table has data in it at this time. The script has code that creates a temp table and ...

Performance of Sql subqueriesfunctions

I am currently working on a particularly complex use-case. Simplifying below :) First, a client record has a many-to-one relationship with a collection of services, that is, a single client may have ...

selecting one value out of an xml column

I have a particularly troublesome xml column to query data from. The schema is fixed by the Quebec Ministry of Revenue so "it is what it is" The important part of the query looks like this: with ...

Selecting records during recursive stored procedure

I ve got a content management system that contains a hierarchical structure of categories, with sub-categories subject to different ordering options at each level. Currently, that s retrieved by a (...

热门标签