Sql Practice 2
之前写了一个SP用来向dimention table插入0 -1 dummy row的值,但今天在process adventureworksdw2008示例
数据库的时候报错,查看了一下,是因为自己当时实验时插入的数据有问题,就想清除掉这些数据.
本想使用sp_Msforeachtable 但一直报错 不能识别$identity.
exec sp_MSforeachtable @command1="delete from '?'" ,@whereand='and $identity < 1'
只好写下了如下的代码:
declare @tables table(tablename varchar(200)) declare @tablename varchar(200) declare @sql nvarchar(2000) insert into @tables select name from sys.tables where name like 'Dim%' while exists(select * from @tables) begin select top 1 @tablename = tablename from @tables delete from @tables where tablename =@tablename set @sql = N'delete from ' + @tablename + ' where $identity < 1' print @sql execute sp_executesql @sql end
Sql Practice 2的更多相关文章
- Sql practice
employee表 数据准备 use tempdb go if OBJECT_ID('employee') is not null drop table employee ;with employee ...
- 历经15个小时,终于评出这8本最受欢迎的SQL书籍
文章发布于公号[数智物语] (ID:decision_engine),关注公号不错过每一篇干货. 来源 | 程序员书库(ID:OpenSourceTop) 原文链接 | https://www.lif ...
- Atitit 数据存储视图的最佳实际best practice attilax总结
Atitit 数据存储视图的最佳实际best practice attilax总结 1.1. 视图优点:可读性的提升1 1.2. 结论 本着可读性优先于性能的原则,面向人类编程优先于面向机器编程,应 ...
- The Practice of .NET Cross-Platforms
0x01 Preface This post is mainly to share the technologies on my practice about the .NET Cross-Platf ...
- 谈一谈SQL Server中的执行计划缓存(上)
简介 我们平时所写的SQL语句本质只是获取数据的逻辑,而不是获取数据的物理路径.当我们写的SQL语句传到SQL Server的时候,查询分析器会将语句依次进行解析(Parse).绑定(Bind).查询 ...
- Partitioning & Archiving tables in SQL Server (Part 1: The basics)
Reference: http://blogs.msdn.com/b/felixmar/archive/2011/02/14/partitioning-amp-archiving-tables-in- ...
- 可输出sql的PrepareStatement封装
import java.io.InputStream; import java.io.Reader; import java.net.URL; import java.sql.Connection; ...
- sql是如何执行一个查询的!
引用自:http://rusanu.com/2013/08/01/understanding-how-sql-server-executes-a-query/ Understanding how SQ ...
- C#读写SQL Server数据库图片
效果图: 下载链接: http://download.csdn.net/detail/u010312811/9492402 1.创建一个Winform窗体,窗体分为“数据上传”和“数据读取”两部分: ...
随机推荐
- C#组态控件Iocomp应用案例
Iocomp组件需要在vs2010环境下使用,目前用到的是4.04版本.在两个项目中用到了它,一个是锅炉监控系统,另一个是绝缘靴检测系统. 锅炉监测系统 这个节目基本都是使用Iocomp控件完成. 出 ...
- YEdit
YEdit YEdit is a YAML editor for Eclipse. See the wiki for more details Installation Use the Eclipse ...
- 金山快盘有Linux版了
似乎是2013-09-29最早发出的新闻. 怎么会没有一点传播呢,难道这么不招待见吗? 出品方是中科麒麟. http://www.ubuntukylin.com/applications/showim ...
- 硅谷新闻3--使用Android系统自带的API解析json数据
NewsCenterPagerBean2 bean2 = new NewsCenterPagerBean2(); try { JSONObject object = new JSONObject(js ...
- percona 5.6升级到5.7相关error及解决方法
今早,把开发环境的mysql升级到了5.7.15,5.6数据导入后,启动一切正常,检查.err日志,发现有如下异常: 2016-10-31T00:29:33.187073Z 0 [Warning] S ...
- SQL数据库基础(七)
主键 数据库主键是指表中一个列或列的组合,其值能唯一地标识表中的每一行.这样的一列或多列称为表的主键,通过它可强制表的实体完整性.当创建或更改表时可通过定义 PRIMARY KEY约束来创建主键.一个 ...
- 拖拽改变div的大小
拖拽改变div的大小 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type&qu ...
- SAPScript、Smartforms动态打印图像或者背景图片
在利用 SMARTFORMS 进行打印的时候有时候要求输出的图片可能是随着打印内容的不同而不同了,也就是动态输出图片,SMARTFORMS的提供了相关的支持技术,下面是实现截图 1.创建要显示的图片 ...
- android res文件夹下面的 values-v11 、 values-v14
values-v11代表在API 11+的设备上,用该目录下的styles.xml代替res/values/styles.xml values-v14代表在API 14+的设备上,用该目录下的styl ...
- Fresco 使用笔记(一):加载gif图片并播放
项目总结 --------------------------------------------------------------------- 前言: 项目中图文混合使用的太多太多了,但是绝大部 ...