Professional Web Applications Themes

Alter Table - Microsoft SQL / MS SQL Server

Taha, Do you really want to add a column on the run?Rethink about the design.If so, you may need to try dynamic sql.Refer the below article by Erland Sommarskog for a discussion on the pros and cons of dynamic sql: The Curse and Blessings of Dynamic SQL http://www.algonet.se/~sommar/dynamic_sql.html -- Dinesh. SQL Server FAQ at http://www.tkdinesh.com "taha" <com> wrote in message news:phx.gbl... ...

  1. #1

    Default Re: Alter Table

    Taha,

    Do you really want to add a column on the run?Rethink about the design.If
    so, you may need to try dynamic sql.Refer the below article by Erland
    Sommarskog for a discussion on the pros and cons of dynamic sql:
    The Curse and Blessings of Dynamic SQL
    http://www.algonet.se/~sommar/dynamic_sql.html


    --
    Dinesh.
    SQL Server FAQ at
    http://www.tkdinesh.com

    "taha" <com> wrote in message
    news:phx.gbl... 


    Dinesh.T.K Guest

  2. #2

    Default Alter table

    Hi...
    i want to alter table using query yser, and i want to
    change the data type from numeric to numeric identity.
    after this command -
    "alter table new_khasra_details alter column khasra_id
    numeric IDENTITY "
    it gives the following error---
    Server: Msg 156, Level 15, State 1, Line 1
    Incorrect syntax near the keyword 'IDENTITY'.


    Please help

    Thanks
    Manoj
    Manoj Guest

  3. #3

    Default Re: Alter table

    you cannot use 'alter' to add/drop identity property. aside that, you have
    to take note at having numeric identity column - this column must have a
    scale of 0 hence it will be truncated...

    here is a quick demo for ya.

    create table t(i numeric(18,2), j varchar)
    insert t select 1.0,'a' union all select 1.2,'b'
    go
    select top 0 i=identity(numeric,1,1),j
    into t2
    from t
    GO
    set identity_insert t2 on

    insert t2(i,j)
    select i,j
    from t

    set identity_insert t2 off
    go
    select * from t2
    go
    drop table t
    go
    exec sp_rename 't2','t'
    go
    drop table t
    go


    --
    -oj
    Rac v2.2 & QALite!
    http://www.rac4sql.net


    "Manoj" <com> wrote in message
    news:010b01c36941$5af3e570$gbl... 


    oj Guest

Similar Threads

  1. alter table alter column syntax problem
    By Chuck in forum MySQL
    Replies: 4
    Last Post: September 5th, 05:17 PM
  2. ALTER TABLE ALTER COLUMN
    By Jacco in forum Microsoft SQL / MS SQL Server
    Replies: 2
    Last Post: August 7th, 05:59 PM
  3. alter a DMS table space
    By xixi in forum IBM DB2
    Replies: 0
    Last Post: August 4th, 09:18 PM
  4. alter table/tables
    By Jacco Schalkwijk in forum Microsoft SQL / MS SQL Server
    Replies: 1
    Last Post: July 11th, 08:41 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139