求一个存储教程表一:
sortid   sort  表二:
typeid  typname  sortid表三:
id   typeid  sort   typename  prio
求取得表一,表二的数据一起插入到表三的存储教程
具体实现是
表一为部门
表二为员工
表一与表二实现联动prio是textbox一起通过web界面提交到数据库表三.

解决方案 »

  1.   


    表一(字段):
    sortid   sort  表二(字段):
    typeid  typname  sortid表三(字段):
    id   typeid  sort   typename  prio
    求一个存储过程:将表一,表二的数据一起插入到表三
      

  2.   

    要是用存储过程:
    Create Proc Submit
        @Prio varchar(100)
    As   insert 表三 select a.sortid,typeid,sort,typename,@prio from [表1] a Inner Join [表二] b On a.sortId=b.sortId
      

  3.   

    如果这样行吗??
    但是报错,错误207,sortid列名无效.create proc classproc
    (
    @sortid int,
    @typeid int,
    @prio varchar(50))
    as
    declare @sort varchar(50)
    select @sort=sort from class_1 where sortid= @sortid
    declare @typename=typename  varchar(50)
    select @typename from class_2 where typeid=@typeid
    insert class_3(sortid,typeid,sort,typename,prio) values (@sortid, @typeid, @sort, @typename, @prio)
    go
      

  4.   

    Create Proc Submit
        @Prio varchar(100)
    As   insert 表三 select a.sortid,typeid,sort,typename,@prio from [表1] a Inner Join [表二] b On a.sortId=b.sortId
     提示插入错误啊
      

  5.   

    chuifengde(树上的鸟儿) 你有Q吗,我的是33428845
      

  6.   

    表一(class_1):
    sortid   sort  
    1         研发部表二(class_2):
    typeid  typname  sortid
    1        张三       1表三(class_3):
    id   typeid  sort   typename  prio
    怎样取得表一的部门,表二的姓名与textbox(prio)的值一起插入到表三注:表一与表二是dropdownlist形成联动
      

  7.   

    chuifengde(树上的鸟儿) 在吗
      

  8.   

    chuifengde(树上的鸟儿) 在吗
      

  9.   

    chuifengde(树上的鸟儿) 在吗
      

  10.   

    --建表
    if object_id('department') is not null
    drop table department
    go
    create table department(sortid int,sort varchar(100))
    go
    if object_id('employee') is not null
    drop table employee
    go
    create table employee(typeid int,typename varchar(100),sortid int)
    go
    if object_id('de') is not null
    drop table de
    go
    create table de([id] int identity,typeid int,sort varchar(100),typename varchar(100),prio varchar(100))
    go--插值
    insert department select 1,'管理' union select 2,'业务'
    insert employee select 1,'王一',1 union select 2,'张三',1 union select 3,'李四',2
    go--创建
    CREATE PROCEDURE submit
    AS
    insert de(typeid,sort,typename) select e.typeid,d.sort,e.typename
    from department d,employee e
    where d.sortid=e.sortid
    GO--执行
    exec submit