Add a column with default value while creating the new table

I am using the following query statement.  I need to add an additional flag column to the new table "CLMU1" with a default value of "1" for each line that is created in the new table.

 

SELECT     CLDISPENSE.COMPANY, CLDISPENSE.SSNO, CLDISPENSE.FACILITY, CLDISPENSE.INTERNAL, CLDRCRED.DOCTOR, CLDISPENSE.DISPENSEDATE, CLDISPENSE.NOTE
INTO            CLMU1
FROM         CLDISPENSE LEFT OUTER JOIN
                      CLDRCRED ON CLDISPENSE.COMPANY = CLDRCRED.COMPANY AND CLDISPENSE.USERCODE = CLDRCRED.PROVID
DaneanAsked:
Who is Participating?
 
IrogSintaConnect With a Mentor Commented:
Try this:
SELECT CLDISPENSE.COMPANY, CLDISPENSE.SSNO, CLDISPENSE.FACILITY, CLDISPENSE.INTERNAL, CLDRCRED.DOCTOR, CLDISPENSE.DISPENSEDATE, CLDISPENSE.NOTE, 1 AS NameOfFlag
INTO CLMU1
FROM CLDISPENSE LEFT OUTER JOIN CLDRCRED ON CLDISPENSE.COMPANY = CLDRCRED.COMPANY AND CLDISPENSE.USERCODE = CLDRCRED.PROVID

Open in new window

0
 
DaneanAuthor Commented:
Thank you.  Perfect!!
0
 
Easwaran ParamasivamCommented:
You can use default constraint. Please do refer the link:

http://blog.sqlauthority.com/2011/04/09/sql-server-add-new-column-with-default-value/
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.