Syntax of for-loop in SQL Server

0 votes
What is the syntax of a FOR loop in TSQL?
Feb 15, 2022 in Database by Vaani
• 7,070 points
924 views

1 answer to this question.

0 votes

TSQL has no for-loop, we have only while-loop.
Your query will look like this:

DECLARE @i int = 0

WHILE @i < 20
BEGIN
    SET @i = @i + 1
    
END
answered Feb 15, 2022 by Neha
• 9,020 points

Related Questions In Database

0 votes
0 answers

How Stuff and 'For Xml Path' work in SQL Server?

Table is: Id Firstname 4 abc 4 def 4 ghi 4 jkl 4 mno Required output: Id Name 4 abc,def,ghi,jkl,mno Query: SELECT ID, ...READ MORE

Feb 23, 2022 in Database by Neha
• 9,020 points
6,002 views
0 votes
0 answers

Display names of all constraints for a table in Oracle SQL

I have given each constraint a name ...READ MORE

Aug 15, 2022 in Database by Kithuzzz
• 38,000 points
877 views
0 votes
0 answers

SQL Server FOR EACH Loop

SQL query: DECLARE @MyVar datetime = '1/1/2010' ...READ MORE

Aug 18, 2022 in Database by Kithuzzz
• 38,000 points
5,009 views
0 votes
1 answer

How do I UPDATE from a SELECT in SQL Server?

MERGE INTO YourTable T USING ...READ MORE

answered Feb 3, 2022 in Database by Vaani
• 7,070 points
830 views
0 votes
0 answers

How do I UPDATE from a SELECT in SQL Server?

INSERT INTO Table (col1, col2, col3) SELECT col1, ...READ MORE

Feb 4, 2022 in Database by Vaani
• 7,070 points
555 views
0 votes
1 answer

What is a stored procedure?

A stored procedure is a set of ...READ MORE

answered Feb 4, 2022 in Database by Neha
• 9,020 points
1,067 views
0 votes
1 answer

LEFT JOIN vs. LEFT OUTER JOIN in SQL Server

At the top level there are mainly ...READ MORE

answered Feb 4, 2022 in Database by Neha
• 9,020 points
2,000 views
0 votes
1 answer

SQL Server replaces LEFT JOIN for LEFT OUTER JOIN in view query

You are getting the joins confused and ...READ MORE

answered Feb 4, 2022 in Database by Neha
• 9,020 points
1,503 views
0 votes
1 answer

Ordering by the order of values in a SQL IN() clause

Use MySQL's FIELD() function: SELECT name, description, ... FROM ... WHERE id ...READ MORE

answered Feb 4, 2022 in Database by Neha
• 9,020 points
5,339 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP