Sql Sever怎么将表中的数据通过存储过程添加到另一个数据库表中

清澈的风 2019-12-23 04:14:45
列如现有A、B两个数据库,想要通过存储过程实现将A数据库中A_Table表中“num”字段大于5的数据存入B_Table中数据存入到B数据库B_Table表中,请问要怎么写呢?


同时写添加定时作业
...全文
243 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
独木成林_ 2019-12-23
  • 打赏
  • 举报
回复
引用 3 楼 独木成林_ 的回复:
[quote=引用 2 楼 清澈的风 的回复:] [quote=引用 1 楼 独木成林_ 的回复:]


Insert Into B.dbo.table
Select * From A.dbo.table Where Len(num) > 5

我想要用存储过程,然后添加为定时作业[/quote]

Create Procedure Pro_Table
as
	Insert Into B.dbo.table
	Select * From A.dbo.table Where Len(num) > 5 --條件根據實際需求進行添加,不然會造成大量數據冗餘。
go

--將下面這句放入排程中並設定好排程執行時間
Exec Pro_Table
[/quote] 條件根據實際需求進行添加,不然會造成大量數據冗餘。
独木成林_ 2019-12-23
  • 打赏
  • 举报
回复
引用 2 楼 清澈的风 的回复:
[quote=引用 1 楼 独木成林_ 的回复:]


Insert Into B.dbo.table
Select * From A.dbo.table Where Len(num) > 5

我想要用存储过程,然后添加为定时作业[/quote]

Create Procedure Pro_Table
as
	Insert Into B.dbo.table
	Select * From A.dbo.table Where Len(num) > 5 
go

--將下面這句放入排程中並設定好排程執行時間
Exec Pro_Table
清澈的风 2019-12-23
  • 打赏
  • 举报
回复
引用 1 楼 独木成林_ 的回复:


Insert Into B.dbo.table
Select * From A.dbo.table Where Len(num) > 5



我想要用存储过程,然后添加为定时作业
独木成林_ 2019-12-23
  • 打赏
  • 举报
回复


Insert Into B.dbo.table
Select * From A.dbo.table Where Len(num) > 5

22,207

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧