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窗体,窗体分为“数据上传”和“数据读取”两部分: ...
随机推荐
- html+css—two
1.滚动字幕(不常用) 默认状态:<marquee>向左移动</marquee> //-- hspasc滚动区域height滚动字幕高度 <marquee height= ...
- The type java.util.Map$Entry cannot be resolved. It is indirectly referenced。。.相似的错误
这个问题是出现一般都是因为JDK版本的问题.今天公司安装NC的时候就出现了这个问题.经过对错误的分析和猜测,将JDK从1.8i换成了1.7,之后就行了.根据我个人的猜测,可能是1.8以后就不支持Map ...
- A -- HDU 4585 Shaolin
Shaolin Time Limit: 1000 MS Memory Limit: 32768 KB 64-bit integer IO format: %I64d , %I64u Java clas ...
- rabbitmq学习笔记2 基本概念
官网:http://www.rabbitmq.com 参考:http://blog.csdn.net/column/details/rabbitmq.html 1 基本概念 rabbitmq se ...
- 链接错误——无法解析的外部符号 ConvertStringToBST
今天做COM组件时,编译之后,出现了一个数个编译错误:error LNK2019: 无法解析的外部符号 "wchar_t * __stdcall _com_util::ConvertStri ...
- DevExpress中透明玻璃效果
Aero玻璃效果 下图左是DevExpress无玻璃效果,图右是Windows自带玻璃效果. Windows Aero 是从 Windows Vista 开始使用的新型用户界面,透明玻璃感让用户一眼贯 ...
- android 打包错误
打包时报如下错误: Export aborted because fatal lint errors were found. These are listed in the Lint View. Ei ...
- NSArray数字和排序
1.数字 int main(int argc, const char * argv[]) { @autoreleasepool { //添加空白 [NSNull null] // NSArray *a ...
- iOS 完美解决 interactivePopGestureRecognizer 卡住的问题
interactivePopGestureRecognizer是iOS7推出的解决VeiwController滑动后退的新功能,虽然很实用,但是坑也很多啊,用过的同学肯定知道问题在哪里,所以具体问题我 ...
- img 在层内 居中显示
div{width:250px;height:150px;background:#000;position:relative;} img{;;;;margin: auto;} <div>& ...