Hi, Cyrus and Rudy ! If you see this topic.
Now I got a problem in execute a stored procedure which will create a variable field names.Here is my stored procedure

Create procedure QC_User
@prod_date char(8)
as
declare @start datetime
declare @end datetime
set @start = convert(datetime,@prod_date)
set @start = convert(char(10),@start,121) + ' 07:00:00'

-- Cyrus had taught me like this statement below,thanks ! Now I can use the DATEADD() function.
set @end = dateadd(dd,1,@start)
-- set @end = @start + 1

-- this will turn into field name !
declare @model char(10)

-- the statement that will be used to modify the new temp table's structure
declare @edit char(200)

-- get all data for the given date
select * into #tp1 from history where ws_no = '030' and prod_date >= @start and prod_date < @end

-- retrieve all userid for the target
select userid into #result from history where ws_no = '030' and prod_date >= '2003-10-23 07:00:00' group by userid

-- retrieve all model's name
select model into #model from #tp1 group by model

-- the first cursor for modifying the target temp table
declare model cursor for
select model from #model order by model

open model
fetch next from model into @model
WHILE @@FETCH_STATUS = 0
BEGIN
-- Because the data item with "-" in it, I have to put it in the square brackets
-- In fact, the statement I write below is learned from here!
set @edit = 'alter table #result add [' + @model + '] int'
exec(@edit)

fetch next from model into @model
END
close model
deallocate model

-- until now, the target table has been made correctly.
-- select * from #result

-- the data which will be written into the new temp table.
select userid,model,count(bl_no) qty into #detail from #tp1 group by userid,model

-- From this statement my problem is starting!
declare model cursor for
select model from #detail

-- I recreate the cursor in the same name. I think this should be more efficient, did it ?
open model
fetch next from model into @model
WHILE @@FETCH_STATUS = 0
BEGIN
set @edit = 'update #result set #result.[' + @model +']= #detail.qty from #detail where #result.userid = #detail.userid and #result.model = ' + @model

-- the statement below got problems!
-- exec(@edit)
print @edit
fetch next from model into @model
END

close model
deallocate model
-- END
The result I printed out for @edit is as below:

update #result set #result.[ABCD-E ]= #detail.qty from #detail where #result.userid = #detail.userid and #result.model = ABCD-E

The result is almost right! But it is still makes some errors with it. I think this result may be two errors at least. The first one is the field name of the #result in the square brackets has some space while the ABCD-E is not. The second one should be the absent of the single parentheses outside the ABCD-E.But I can not solve it at all. Please Help me !