create table #t(
[城市] varchar(30),
[城市ID] int)
go
insert into #t (exec  PCS_Z_CS_purview  3,'zzf' ) 
go
select 城市,城市ID from #t
go

解决方案 »

  1.   

    create table #table(id int identity,txt varchar(1000))
    insert into #table(txt) exec master..xp_cmdshell 'dir c:\*.'
    select * from #table用存储过程插入数据
    在INSERT 语句中可以通过执行存储过程来取得要插入的数据所插入的数据是存储
    过程中SELECT 语句所检索的结果集使用存储过程插入数据的语法如下
    INSERT [INTO]
    { table_name WITH ( <table_hint_limited> [...n])
    | view_name
    | rowset_function_limited }
    { [(column_list)]
    EXECUTE procedure
    其中procedure 既可以是一个已经存在的系统存储过程或用户自定义的存储过程也
    可以在INSERT 语句中直接编写存储过程
    例11-4 对每个部门求员工工资总额并把结果存入department_info 表中
    use pangu
    insert into department_info(dept_id, d_wage)
    execute ('select dept_id, sum(e_wage)
    from employee
    group by dept_id')
    select * from department_info
    运行结果如下
    (7 row(s) affected)
    dept_id d_chief_name d_location e_num d_wage
    ------- -------------------- -------------------------------------------------- ------ ------------
    1001 dbo NULL NULL 15000.0000
    1002 dbo NULL NULL 19500.0000