Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 396 Vote(s) - 3.54 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to ALTER multiple columns at once in SQL Server

#11
If you don't want to write the whole thing yourself and change all the columns to the same datatype this can make it easier:

select 'alter table tblcommodityOHLC alter column '+name+ 'NUMERIC(18,0);'
from syscolumns where id = object_id('tblcommodityOHLC ')

You can copy and paste the output as your query
Reply

#12
Doing multiple `ALTER COLUMN` actions inside a single `ALTER TABLE` statement is not possible.

See the `ALTER TABLE` syntax [here][1]

You can do multiple `ADD` or multiple `DROP COLUMN`, but just one `ALTER
COLUMN`.


[1]:

[To see links please register here]

Reply

#13
As others have answered, you need multiple `ALTER TABLE` statements.
Try following:

ALTER TABLE tblcommodityOHLC alter column CC_CommodityContractID NUMERIC(18,0);
ALTER TABLE tblcommodityOHLC alter column CM_CommodityID NUMERIC(18,0);
Reply

#14
This is **not possible**. You will need to do this one by one.
You could:

1. Create a Temporary Table with your modified columns in
2. Copy the data across
3. Drop your original table (Double check before!)
4. Rename your Temporary Table to your original name
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through