insert into aa(incid)select Max(id) from bb where id is not null;
现在是将bb表中最大id填充到aa表incid这个字段中
但是我不单单只是填充 bb表中的id  我还有变量需要填充到aa这个表中的字段上去,
insert into aa(incid,content)select Max(id) from bb where id is not null;
content这个字段是变量 但不是从bb表的,这个后面的语句应该怎么写呢

解决方案 »

  1.   

    是要这样的吗?declare @p varchar(50)
    set @p='abcd'
    insert into aa(incid,content)
    select Max(id),@p from bb where id is not null
      

  2.   

    insert into aa(incid,content) values(select Max(id) from bb where id is not null, content)
    這樣可以嗎
      

  3.   

    insert into aa(incid,content) values(select Max(id) from bb where id is not null, content)
    這樣可以嗎
    ===========================================================
    这样执行不了
    insert into aa(incid,content)select Max(id) from bb where id is not null,'"+index+"';
    select Max(id) from bb where id is not null是填充incid的 content这个是变量
    我要的是这样 ` 但是我那样写 不正确
      

  4.   

    insert into aa(incid,content)select Max(id) from bb where id is not null,'"+index+"';
    其實select Max(id) from bb where id is not null就是取一個最大id值,declare @p int
    select @p = Max(id) from bb where id is not null
    insert into aa(incid,content) values(@p,'"+index+"')
      

  5.   

    存储过程??没说要用存储过程阿。
    给你的不都是sql语句吗,你想怎么用都可以啊,直接用在程序里头也可以啊
      

  6.   

    呵呵` 好了  刚把这个declare @p int弄错了 `
      

  7.   

    string[] textboxs = new string[inc];
                        for (int t = 1; t < inc; t++)
                        {
                            textboxs[t] = Request.Form["tdvc" + t.ToString()];
                            string sqlupdate = "update movie_play set playcontent='" + textboxs[t] + "' where movieid=" + editid;
                            SqlCommand mycommandb = new SqlCommand(sqlupdate, myconn);
                            mycommandb.ExecuteNonQuery();                    }
    请问我这样为可更新不了数据呢,tdvc这个是动态的textbox值,吸收循环更新数据库,