Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    Posts
    29

    Unanswered: Basic Cursor Loop Question

    Using Sybase / TSQL.

    Table has one column, ID (varchar(2))

    I want to use a cursor and a while loop to print the contents of the table to an output file (c:\test.txt) and to the query window.

    Also, using an IF to print all results starting with "S".

    Thanks.

  2. #2
    Join Date
    Mar 2001
    Location
    Lexington, KY
    Posts
    606
    Couldn't you just use a stored procedure:
    Code:
    CREATE PROCEDURE foo
    AS
      DECLARE @id VARCHAR( 2 )
      SELECT @id = ID
    	FROM yourTable
       WHERE ID LIKE 'S%'
      
       print @id
    
       -- Write to file via an extended proc maybe?
      
    GO
    Thanks,

    Matt

Posting Permissions

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