Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Simple TSQL cursor (See related posts)

// Simple TSQL cursor

        declare @email nvarchar(255)
        declare CustList cursor for
                SELECT email from STE_EMAILS
        OPEN CustList
        FETCH NEXT FROM CustList 
        INTO @email
        WHILE @@FETCH_STATUS = 0
        BEGIN
          if (SELECT count(custid) from leads where (current_customer=1) and (notes1 is not null) and (notes1 like '%' + @email + '%')) > 0
                SELECT custid from leads where (current_customer=1) and (notes1 is not null) and (notes1 like '%' + @email + '%')
                print '%' + @email + '%'
          FETCH NEXT FROM CustList INTO @email
        END
        CLOSE CustList
        DEALLOCATE CustList

You need to create an account or log in to post comments to this site.


Related Posts