Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 While and Print

Author  Topic 

Lopaka
Starting Member

48 Posts

Posted - 2010-02-10 : 13:55:27
I have a print statement in a loop that lets me know where it is at... Unfortunately, the print only works at the end of the loop. Is there a way to force the print to work as it passes in the loop?

Thanks you

Robert R. Barnes

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-10 : 13:59:27
it should work as long as print is within the loop.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Lopaka
Starting Member

48 Posts

Posted - 2010-02-10 : 14:04:37
The print is in the loop. there are three loops, at exit the loop prints out a all of the info and not durring the loops... any ideas?

Robert R. Barnes
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-10 : 14:20:54
can you show your query?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Lopaka
Starting Member

48 Posts

Posted - 2010-02-10 : 15:12:12
WHILE @PK < @MAX_PK
BEGIN
SET @PK = @PK + 1
SELECT @Table = tName,
@TableDate = tDate
FROM #TableList WHERE PK = @PK

-- Populate the officers table based on the financial data...
SET @SQL_Insert =
'INSERT INTO GS_Data.dbo.EO_Officers_NEW(' +
'fin_id, eName, eTitle, eHours, eCompensation, eBenefits, eOther) ' +
'SELECT b.Fin_ID, LEFT(UPPER(b.ename), 75), LEFT(UPPER(title), 150), LEFT([hours], 150), compensation, benefits, other ' +
'FROM gs_data.dbo.EO_Financials_NEW a LEFT JOIN ' +
'gs_data.dbo.' + @Table + ' b ON a.fin_id = b.fin_id ' +
'WHERE a.TableDate = ''' + @TABLEDATE + ''' ' +
'AND b.fin_id IS NOT NULL'

PRINT 'Inserting ' + @Table
EXECUTE(@SQL_Insert)

PRINT 'OFFICER - NEXT TABLE'
END

Robert R. Barnes
Go to Top of Page
   

- Advertisement -