What is the syntax for a for loop in TSQL?

loop  报错

英 [luːp]  美 [lup]  口语练习
  • vi. 打环;翻筋斗
  • n. 环;圈;弯曲部分;翻筋斗
  • vt. 使成环;以环连结;使翻筋斗

syntax  报错

英 ['sɪntæks]  美 ['sɪntæks]  口语练习 跟读
  • 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 

  

转载于:https://www.cnblogs.com/871735097-/p/3867233.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值