What is the syntax for a for loop in TSQL?
loop 报错
- vi. 打环;翻筋斗
- n. 环;圈;弯曲部分;翻筋斗
- vt. 使成环;以环连结;使翻筋斗
syntax 报错
- n. 语法;句法;有秩序的排列
1
@Macho more info needed – true May 20 '11 at 7:56
8
SQL is a very different language compared to what you're used to. It's focused on what, not how. You tell SQL Server what results you want, and let it figure out how to produce the answer. Or, to repharse what I've just said - there isn't a for loop in SQL. – Damien_The_Unbeliever May 20 '11 at 7:58
3
WHILE @I < 10; SET @I = @I + 1; BEGIN; ...; END? However, this should not be used for most query processing (but is sometimes required for imperative manipulation). Many such instructions/hints are available on google using the search "tsql for loop". – user166390 May 20 '11 at 7:58
5
Avoid loops in favour of JOINs and set operations. – Oded♦ May 20 '11 at 7:59
2
If you are not expert in SQL, you should not be considering using a loop. There are only a few conditions where one is needed and most of the rest of the time, using a loop is the equivalent of pushing your car instead of driving it. Learn to think in terms of data sets instead of looping through records. LOoping is an expert level function not because the syntax is hard but because you need to know exactly how much harm you can do with it before you should be allowed to use it. – HLGEM Aug 14 '13 at 21:06
What is the syntax for a for loop in TSQL?的更多相关文章
- linux shell 报错 Syntax error: Bad for loop variable
在linux下写了一个简单的shell,循环10次. test.sh #!/bin/bash ## ##循环10次 ## ; i<; i++)); do echo Good Morning ,t ...
- linux shell scripts:Syntax error: Bad for loop variable
执行脚本报错 #!/bin/bash s=0 for (( i=1; i<=100; i++ )) do s=$(( $s + $i )) done echo $s sh add.sh 报错: ...
- shell脚本:Syntax error: Bad for loop variable错误解决方法(转)
Linux Mint中写了一个简单的shell脚本,利用for..do..done结构计算1+2+3......+100的值,结果执行"sh -n xxx.sh"检测语法时总是报错 ...
- Syntax error: Bad for loop variable解决办法
从 ubuntu 6.10 开始,ubuntu 就将先前默认的bash shell 更换成了dash shell:其表现为 /bin/sh 链接倒了/bin/dash而不是传统的/bin/bash. ...
- (转)Syntax error:
但是运行时总是报下面这个错,如下: test11-loop.sh: 5: Syntax error: Bad for loop variable 几经查找语法,没有问题,后来在网上找到问题原因: 代码 ...
- Mysql控制语句
14.6.5.1 CASE Syntax 14.6.5.2 IF Syntax 14.6.5.3 ITERATE Syntax 14.6.5.4 LEAVE Syntax 14.6.5.5 LOOP ...
- OpenMP for Fortran
OpenMP for Fortran OpenMP Directive Syntax of OpenMP compiler directive for Fortran: !$OMP Directive ...
- ABAP-语法检查
1.界面 2.代码 *&---------------------------------------------------------------------* *& Report ...
- ubuntu 下执行定时任务
Window shell文件在linux系统下执行不了的解决办法 一些人喜欢用vim来写linux shell script, 但是, 有的人喜欢在Windows下用一些方便的编辑器(比如鼎鼎大名的N ...
随机推荐
- 基于C++ STL sort函数对c++ string 进行字符串的局部排序
Paypal笔试挂了,因为好久没有在leedcode之类的网上写代码,字符输入调了半天,时间都用光了.... Description: 有一个字符串,现在对其进行多次局部排序,例如str=" ...
- ElasticSearch中"distinct","count"和"group by"的实现
最近在业务中需要使用ES来进行数据查询,在某些场景下需要对数据进行去重,以及去重后的统计.为了方便大家理解,特意从SQL角度,方便大家能够理解ES查询语句. 1 - distinct ; { &quo ...
- 未安装发布所需的web发布扩展
解决方案:需要安装web deploy 下载网站:https://www.iis.net/downloads/microsoft/web-deploy 假如还是打不开的话,估计时打开方式错误了, 要用 ...
- 《学渣Linux笔记》——更改ls命令的输出颜色和命令提示符颜色(二)
<学渣Linux笔记>--更改ls命令的输出颜色和命令提示符颜色(二) II.更改命令提示符颜色 命令提示符的显示格式是由变量PS1决定的,首先我们查找GNU官方手册,发现如下内容(不是我 ...
- 查询系统table条数
), RowCnt INT) EXEC sp_MSforeachtable 'INSERT INTO temp SELECT ''?'',COUNT(*) FROM ?' SELECT TableNa ...
- python_进程与线程的补充
进程与线程的标识 知识点一:进程id 与 线程ident import time import multiprocessing import threading time.sleep(10) prin ...
- python_dict json读写文件
命令汇总: json.dumps(obj) 将python数据转化为json Indent实现缩进,ensure_ascii 是否用ascii解析 json.loads(s) 将json数据转换为py ...
- ELK学习笔记之logstash的各个场景应用(配置文件均已实践过)
详细请参考该文 https://www.cnblogs.com/qingqing74647464/p/9378385.html
- SQL Server——死锁查看
一.通过语句查看 --查询哪些死锁SELECT request_session_id spid, OBJECT_NAME( resource_associated_entity_id ) tableN ...
- C# vb .net实现焦距灰度特效滤镜
在.net中,如何简单快捷地实现Photoshop滤镜组中的焦距灰度效果呢?答案是调用SharpImage!专业图像特效滤镜和合成类库.下面开始演示关键代码,您也可以在文末下载全部源码: 设置授权 第 ...