WHILE with AND operator : while « Transact SQL « SQL Server / T-SQL Tutorial

SQL Server / T-SQL Tutorial
1. Query
2. Insert Delete Update
3. Table
4. Table Join
5. Data Types
6. Set Operations
7. Constraints
8. Subquery
9. Aggregate Functions
10. Date Functions
11. Math Functions
12. String Functions
13. Data Convert Functions
14. Analytical Functions
15. Sequence Indentity
16. View
17. Index
18. Cursor
19. Database
20. Transact SQL
21. Procedure Function
22. Trigger
23. Transaction
24. XML
25. System Functions
26. System Settings
27. System Tables Views
28. User Role
29. CLR
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
SQL Server / T-SQL Tutorial » Transact SQL » while 
20. 8. 8. WHILE with AND operator
1CREATE TABLE Orders (
2>      OrderID int NOT NULL ,
3>      CustomerID nchar (5NULL ,
4>      EmployeeID int NULL ,
5>      OrderDate datetime NULL ,
6>      RequiredDate datetime NULL ,
7>      ShippedDate datetime NULL ,
8>      ShipVia int NULL ,
9>      Freight money NULL DEFAULT (0),
10>     ShipName nvarchar (40NULL ,
11>     ShipAddress nvarchar (60NULL ,
12>     ShipCity nvarchar (15NULL ,
13>     ShipRegion nvarchar (15NULL ,
14>     ShipPostalCode nvarchar (10NULL ,
15>     ShipCountry nvarchar (15NULL
16)
17> GO
1>
2>
3INSERT INTO Orders VALUES (10248,'1',5,'7/4/1996','8/1/2001','7/16/2001',3,32.38,'V','A','R',        NULL,N'51100','France')
9> go
1>
2>
3>    create PROCEDURE spCursorScope
4>    AS
5>    DECLARE @Counter      int,
6>            @OrderID      int,
7>            @CustomerID   varchar(5)
8>    DECLARE CursorTest cursor
9>    LOCAL
10>    FOR
11>       SELECT OrderID, CustomerID
12>       FROM Orders
13>
14>    SELECT @Counter = 1
15>    OPEN CursorTest
16>    FETCH NEXT FROM CursorTest INTO @OrderID, @CustomerID
17>    PRINT 'Ro' + CONVERT(varchar,@Counter' has an OrderID of ' +
18>          CONVERT(varchar,@OrderID' and a CustomerID of ' + @CustomerID
19>
20>    WHILE (@Counter<=5AND (@@FETCH_STATUS=0)
21>    BEGIN
22>          SELECT @Counter = @Counter + 1
23>          FETCH NEXT FROM CursorTest INTO @OrderID, @CustomerID
24>          PRINT 'Ro' + CONVERT(varchar,@Counter' has an OrderID of ' +
25>          CONVERT(varchar,@OrderID' and a CustomerID of ' + @CustomerID
26>    END
27>    GO
1>
2>    drop PROCEDURE spCursorScope;
3>    GO
1>
2>    drop table Orders;
3>    GO
20. 8. while
20. 8. 1. How to perform repetitive processing
20. 8. 2. WHILE @@FETCH_STATUS = 0
20. 8. 3. This procedure inserts rows by using while loop
20. 8. 4. Insert 100 rows of data: RAND
20. 8. 5. While with counter
20. 8. 6. Use while loop to insert data
20. 8. 7. While loop controlled by an aggregate function
20. 8. 8. WHILE with AND operator
20. 8. 9. A script that tests and adjusts credit amounts with a WHILE loop
20. 8. 10. Using a Subquery with a Single-Statement WHILE Loop
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.