Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2002
    Location
    Holland
    Posts
    6

    Unanswered: Using recordset in a procedure

    Dear SqlServer,

    As a starting sql server user we allways working in msAccess-97 with recordsets to get information from our databases.
    In sql server I did found the cursor, code:

    USE Northwind
    GO
    DECLARE abc CURSOR FOR
    SELECT * FROM Shippers
    OPEN abc
    FETCH NEXT FROM abc
    WHILE (@@FETCH_STATUS = 0)
    FETCH NEXT FROM abc
    CLOSE abc
    DEALLOCATE abc
    GO

    If this code is filled in in sql serever qery analyzer, all fields are showed. If we want to see only one field, for example the "CompanyName" how do we get this information? (source?)
    Nice regards,

    Michelle

  2. #2
    Join Date
    Mar 2002
    Location
    Holland
    Posts
    6
    test2
    Nice regards,

    Michelle

  3. #3
    Join Date
    Mar 2002
    Location
    Holland
    Posts
    6
    test3
    Nice regards,

    Michelle

  4. #4
    Join Date
    Dec 2001
    Location
    Toronto, Canada
    Posts
    335
    Code:
    USE Northwind 
    GO 
    DECLARE @CompanyName varchar(50)
    
    DECLARE abc CURSOR FOR 
    SELECT CompanyName
    FROM    Shippers 
    
    OPEN abc 
    
    FETCH NEXT FROM abc  INTO @CompanyName 
    
    WHILE (@@FETCH_STATUS = 0) BEGIN
        PRINT @CompanyName 
    
        FETCH NEXT FROM abc  INTO @CompanyName 
    END
    
    CLOSE abc 
    DEALLOCATE abc 
    GO

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •