Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4108826
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:42:38+00:00 2026-05-20T21:42:38+00:00

When I create a temp table using a select into in SQL Server, is

  • 0

When I create a temp table using a select into in SQL Server, is there a way to specify that a column should be nullable? I have a multi-step process where I’m making a temp table by selecting a lot of columns (which is why I’m not doing a create table #tmp (...)). After I make that temp table, I’m updating some columns and some of those updates might null out a field.

I know I could do an alter table alter column statement to achieve what I want, but I’m curious about whether there’s a way to specify this in the select itself. I know you can inline cast your columns to get the desired datatype, but I can’t see how you specify nullability.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T21:42:39+00:00Added an answer on May 20, 2026 at 9:42 pm

    Nullability is inherited from the source column.

    You can lose or gain nullability with an expression:

    Example (constant literals appear to be problematic – need a good NOOP function which can return NULL):

    CREATE TABLE SO5465245_IN
        (
         a INT NOT NULL
        ,b INT NULL
        ) ;
    GO
    
    SELECT  COALESCE(a, NULL) AS a
           ,ISNULL(b, 0) AS b
           ,COALESCE(10, NULL) AS c1
           ,COALESCE(ABS(10), NULL) AS c2
           ,CASE WHEN COALESCE(10, NULL) IS NOT NULL THEN COALESCE(10, NULL) ELSE NULL END AS c3
    INTO    SO5465245_OUT
    FROM    SO5465245_IN ;
    GO
    
    SELECT  TABLE_NAME
           ,COLUMN_NAME
           ,IS_NULLABLE
    FROM    INFORMATION_SCHEMA.COLUMNS
    WHERE   TABLE_NAME LIKE 'SO5465245%'
    ORDER BY TABLE_NAME
           ,ORDINAL_POSITION ;
    GO
    
    DROP TABLE SO5465245_IN ;
    GO
    
    DROP TABLE SO5465245_OUT ;
    GO
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In SQL Server, there's no way to create a temp table on the fly
If I create a temporary table using # sign: SELECT * INTO #temp FROM
I am using SQL Server 2008r2. I have a table with a column defined
What is the difference between: CREATE TABLE #temp ( [ID] INT) INSERT INTO #temp
I have temp table #xml that have 2 columns: CREATE TABLE #xml ( id
I seem to be running into a problem with temp table garbage collection: CREATE
CREATE TABLE #TEMPTABLE ( requestTime datetime2, NoOfSessions integer ) INSERT INTO #TEMPTABLE select convert(nvarchar(16),
I have a table that I need to normalize with many fields In SQL-Server
I am using the exec(query_string) command on sql server. The matter is that the
I'm using Microsoft SQL Server 2005. I'm creating a random record generator that will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.