mister.magoo (8/5/2013)
Amy.G (8/5/2013)
I am creating a table by using theSELECT column1, column2
INTO NewTable
FROM OldTable
method. Is there a way of creating a table in this manner and saying if the columns should be null or not null? Currently I am just using an alter statement to change a column from null to NOT NULL, but was wondering if there is a way to eliminate this step.
Relatedly, can anyone think of a way for me to stop getting obsessed with ways of cutting out 1-2 lines of code and wasting all this time figuring out things I've already found solutions for? :crazy:
Thank you,
Amy
Firstly,
SELECT ISNULL(column1,'') as column1, column2
INTO NewTable
FROM OldTable
column2 is now nullable, column1 is not.
Second question: Yes, spend some quality time answering other peoples obsessive work avoidance questions, then you can at least pretend you are being useful in some way 😀
Column2 is not nullable if it was not nullable in the original table.
I don't know of any way to make a column nullable that was "not nullable" in the source table for a SELECT ... INTO.
SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.