我想将数据从一个服务器的数据库移植到另一个服务器的数据库.这些数据库都位于不同的mssql 2005服务器上.复制可能不是一个选项,因为目标数据库是在[时间间隔]的基础上从头开始生成的.
我倾向于做类似的事情
insert *
from db1/table1
into db2/table2
where rule1 = true
Run Code Online (Sandbox Code Playgroud)
很明显,连接凭据会在这个脚本中出现.
我构建了我的sql表,如下所示:
ItemID Price MaxPeople CalculationUnit
1 10 4 people/item
2 70 2 item
3 30 8 week/item
4 50 2 week
Run Code Online (Sandbox Code Playgroud)
等等
现在我想运行一个类似的基本存储过程
sp_return_items_total
@Days as int,
@Items as int
AS
select itemid, price, total from table
Run Code Online (Sandbox Code Playgroud)
Total将是基于此计算的值(number of days * calculation unit * price).
例如,对于@Days = 5'@Items = 2',结果将是:
1, 10, 400 (10 * 4 people * 2 items * 5 days)
2, 70, 140 (70 * 1 * 2 items * 1)
3, …Run Code Online (Sandbox Code Playgroud)