Null-enable a column question

Hello everyone
My first post here.

I am creating a stored procedure which duplicates a an existing table, and feeds data to its first column only. It turns out that the source table does not allow null values. This latter part is causing problems because whereas it accepts the full syntax:

ALTER TABLE [db].[table1] ALTER COLUMN [column1] NVARCHAR(42) NULL

the following : ALTER TABLE [db].[table1] ALTER COLUMN [column1] NULL

is returning a syntax error.

What would be the most elegant way to make columns null-enabled without changing their other parameters?

Thanks

Hello,

There is not other way. you are not changing the data type unless you actually do change it from for ex varchar(50) to varchar(150)

unless you change things in sys.tables and sys.columns which is not recommended and I am not even sure you can do that.

Which version of SQL Server? It's much easier to generate the code if you're on SQL 2012 or later.

You could write a simple routine which takes a table and column name as parameters, gets the attributes from information_schema.columns then creates a dynamic sql string to update the nullablity then executes it.