sql >> Databasteknik >  >> RDS >> Sqlserver

Få flera värden i SQL Server Cursor

Detta borde fungera:

DECLARE db_cursor CURSOR FOR SELECT name, age, color FROM table; 
DECLARE @myName VARCHAR(256);
DECLARE @myAge INT;
DECLARE @myFavoriteColor VARCHAR(40);
OPEN db_cursor;
FETCH NEXT FROM db_cursor INTO @myName, @myAge, @myFavoriteColor;
WHILE @@FETCH_STATUS = 0  
BEGIN  

       --Do stuff with scalar values

       FETCH NEXT FROM db_cursor INTO @myName, @myAge, @myFavoriteColor;
END;
CLOSE db_cursor;
DEALLOCATE db_cursor;


  1. Hur tar man bort alla icke-alfanumeriska tecken från en sträng i MySQL?

  2. Simulera group_concat MySQL-funktion i Microsoft SQL Server 2005?

  3. MySQL JDBC-drivrutin 5.1.33 - Tidszonsproblem

  4. Hur man kontrollerar inaktuell statistik