Is there a grammar like FOR sentence in MSSQL?

Asked 1 years ago, Updated 1 years ago, 101 views

If there are 10 pieces of data, we will take out data from 1st to 10th, compare it with data from other tables, and then process INSERT or UPDATE.

I wonder if there is a grammar that can be compared by bringing data one by one like a FOR statement in SQL.

mssql sql database

2022-09-22 14:04

2 Answers

First of all, basic SQL alone does not have a grammar similar to a FOR statement.

However, each DBMS vendor supports a function, procedure, that can be used by prescribing a set of commands. The DBMS vendor may provide this procedure when you create it.

Study the procedure part of MSSQL.

Simple example sentence has an example of While Loop.


2022-09-22 14:04

It's called cursor.


2022-09-22 14:04

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.