在SQL中为特定的一组行插入脚本 [英] Insert script for a particular set of rows in SQL

查看:48
本文介绍了在SQL中为特定的一组行插入脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SQL Server2008.我曾经使用任务->生成脚本"选项从SQL表中获取数据脚本.

I am using SQL Server 2008. I use to take the script of my data from SQL table using Tasks --> Generate Scripts option.

这是我的问题:

假设我在 Employee 表中有21,000条记录.当我采用此表的脚本时,它将采用所有21000条记录的插入脚本.如果我只想从表中提取18000条记录的脚本,该怎么办?

Let's say I have 21,000 records in Employee table. When I take the script of this table, it takes the insert script for all 21000 records. What is the solution if I want to take only the script of 18000 records from the table?

是否有使用SQL查询或任务向导的解决方案?

Is there any solution using SQL query or from the tasks wizard?

预先感谢...

推荐答案

创建一个新视图,您可以在其中从Employee表中选择所需的行,例如 SELECT TOP 21000 ...

Create a new View where you select your desired rows from your Employee table e.g. SELECT TOP 21000...

然后简单地脚本化View而不是Table.

Then simply script that View instead of the Table.

这篇关于在SQL中为特定的一组行插入脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆