Does such an operation can be used stored procedures do?

Category: MS-SQL Server -> Foundation Classes Author: a33170 Date: 2012-04-25 13:14:27
 
a33170
2012-04-25 13:14:27

I have a table that is stored real estate appraisers and brokers, which has a field is "whether the appraiser",
data in the table to the other two tables into one is valuation division of tables, one table broker, probably about 2000 records, when this field is "YES", the original table belonging to import information
appraiser valuation Tutor, the other import agent table, I ask you prawn, how to write it with a stored procedure. Is to open the original table, in the cycle of judgment, into two tables stored procedure how to write it.
girlkimono19870828
2012-04-25 13:23:56
create procedure p_test
as
begin
insert into valuation Shibiao select ... from ; real estate appraisers and brokers table where ["whether the appraisers'] = 'yes'

insert into table select ... from brokers real estate appraisers and brokers table where ["whether the appraisers'] <> 'yes'

end
wqjvfbwh1134
2012-04-25 13:33:07
insert into valuation Shibiao
select * from table where whether appraisers = 'yes'

insert into table
select * from brokers whether the table where appraisers = 'No'
cx03164240
2012-04-25 13:37:43
sql statement
import valuation Biao: insert into valuation Biao (field list) select ; the field list from the current table
; ; where whether appraisers = 'yes'
import broker table: insert into broker table (field list) select list of fields from the current table
; where whether appraisers = 'No '
wh986521
2012-04-25 13:47:43
loops do not need to add? Is it written in the program cycle?
Sacre
2012-04-25 14:06:44
need to add cycle
e8az564fda4
2012-04-25 14:20:33
Can a stored procedure in the first loop record, and then use if else and so on, it is up to how to write Yeah
langyun_0405
2012-04-25 14:37:21
declare @ check char (2)
declare cursor1 cursor for
select appraisers determine whether a field from real estate appraiser and brokers Table
open cursor1
fetch next from cursor1 into @ check
while @ @ fetch_status = 0
begin
if @ check = 'yes'
insert into valuation Biao (field list) select list of fields from the current table
else
insert into broker Table (field list) select list of fields from the current table
fetch next from cursor1 into @ check
end
close cursor1
deallocate ; cursor1
this can be achieved, but also some trouble, I suggest you use a method other direct point
singotm
2012-04-25 14:49:18
Thank you, because in some places not so straightforward implementation, you must cycle determine the straight, again each table to add