1>ALTER TABLE --- ADD FieldName TINYINT AFTER ----

解决方案 »

  1.   

    skimeister,好象沒有你所寫的那種用法﹐我試過不行的。如果你
    試了行的話﹐給我一個 sample如何 ﹐謝謝。
    我用了如下SQL STATEMENT:ALTER TABLE Peronnel ADD FName varchar(100) AFTER FID
      

  2.   

    To:bigtree21cn()老兄:
    先说第一个问题,MSSQLSERVER2000:
    假设在数据库'TEST'中有表'TAB',此表结构如下:
    ID(int)   NAME(varchar(8))   SEX(int)
    --------------------------------------------
    现在要把字段‘SEX’调到‘ID’的位置,既由3===>1,则程序如下:use master
    go
    sp_configure 'allow updates',1
    reconfigure with override
    go
    use test --‘TEST’为你的数据库
    go
    declare @ltab varchar(50),@lcol varchar(50),@lorder int,@sum int,@cur int,@tempcur int
    select @ltab='tab',@lcol='sex',@lorder=1 --定义要调的表、列和此列调动后的位置
    if not exists(select * from sysobjects where id=object_id(@ltab))
    begin
    print 'The table '+@ltab+' is not exists!'
    end
    select @sum=count(*) from syscolumns where id=object_id(@ltab)
    if @sum=0 
    begin
    print 'The column '+@lcol+' is not exists!'
    end
    if @lorder>@sum or @lorder<1
    begin
    print 'The order '+cast(@lorder as varchar(100))+' out limit:[1,'+cast(@sum as varchar(100))+']!'
    end
    select @cur=colid from syscolumns where id=object_id(@ltab) and name=@lcol
    select @tempcur=@sum+1
    update syscolumns set colid=@tempcur where id=object_id(@ltab) and name=@lcol
    if @lorder>@cur --向后调
    update syscolumns set colid=colid-1 where id=object_id(@ltab) and colid>@cur and colid<=@lorder
    if @lorder<@cur --向前调
    update syscolumns set colid=colid+1 where id=object_id(@ltab) and colid>=@lorder and colid<@cur
    update syscolumns set colid=@lorder where id=object_id(@ltab) and name=@lcol
    print 'The column '+@lcol+' is on the order!'
    go
    use master
    go
    sp_configure 'allow updates',0
    reconfigure with override
    go声明:由于此过程要对系统表进行操作,一定要慎重!出现问题,概不负责!
      

  3.   

    to:supsuccess(口气不小)
    有沒有更簡單的??
      

  4.   

    可能没有了...我试过ALTER,好象不可以,不知道你实验的怎么样?
      

  5.   


    做一個動態字段的系統﹐比如薪資系統其薪資項目動態增減﹐采用3層結構似乎實現起來很難(用.net實現)﹐因為更新的時候﹐ADO.NET必須有實際欄位名稱及對應的參數(比如updateSqlCommand)傳入,而由于欄位是動態的﹐所以無法在中間層明確定義商業邏輯。因而建立sqlCommand對象時必須動態的生成。在傳統ado中﹐可以直接綁定recordset到一個控件﹐比如DataGrid﹐而不管字段名稱及個數等信息﹐進行更新;然而﹐ado.net似乎沒有提供這樣的功能﹐因為SqlCommand對象必須提供明確的參數才能執行﹐由于字段是動態的﹐所以參數的個數及類型名稱都無法明確確定。由于沒有更深入了解ado.net,所以請教解決方法.
      

  6.   

    >怎样在一组批次的SQL语句中判断其中有任何一条出错,就象VB中 ON ERROR GOTO 
    一样进行错误处理,而不是在每个可能出现错误的语句后面用 @@ERROR 判断.没别的方法,我曾找过微软.