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
 General SQL Server Forums
 New to SQL Server Programming
 loop in tem ptable

Author  Topic 

keizy07
Starting Member

8 Posts

Posted - 2012-03-22 : 05:42:56
>How could I then loop through the records of #orderlisting to update some
blank fields that were created in the intial select statement?



declare cursorName cursor for
select employeeName,customerId,OrderId,OrderDate,OrderAmount,RunningTotal from #orderlisting

declare @employeeName varchar (50)
declare @customerID int
declare @orderId int
declare @OrderDate date
declare @orderAmount int
declare @runningTotal int

insert #orderlisting
exec (@employeeName+@customerId+@OrderId+@OrderDate+@OrderAmount+@RunningTotal)



thanku in advance

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2012-03-22 : 06:32:52
You do not need a cursor to update blank fields.

Update #orderlisting SET <field> = <missing value> WHERE <field> IS NULL OR <field> = ''










How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
   

- Advertisement -