You can add a column to a table and supply a default value (i'm not 100% sure on the 
syntax for DEFAULT):

  ALTER TABLE TableName ADD NewColumnName varchar(100) DEFAULT '24'

You could also do an UPDATE with no where clause statement to change all values in a 
column after you have added it if you don't want the default functionality:

  ALTER TABLE TableName ADD NewColumnName varchar(100)
  UPDATE TableName SET NewColumnName = 24

I am assuming that by "add a column to this query" you really mean "add a column to 
this table".  To add a column to a query, you can always select 'fake' columns:

  SELECT Col1, Col2, Col3, '24' AS myCol
  FROM TableName
  WHERE ...

>>> Ryan Pieszak <[EMAIL PROTECTED]> 05/20/02 11:12AM >>>
I know this is OT, but I've seen some SQL on this list lately, so I figured
I ask:
Let's say I have this query: 

Col1    Col2    Col3 
1       a       10 
2       b       11 
3       c       12 
4       d       13 
5       e       14 
6       f       15 

But I'd like to add a column to this query later in the process, so I'd have
this: 

Col1    Col2    Col3    myCol   
1       a       10      24 
2       b       11      24 
3       c       12      24 
4       d       13      24 
5       e       14      24 
6       f       15      24 

Is there a queryAppend, or something I can use to add a column to a query in
MSSQL? If it makes a difference, every value in the added column will be the
same. Thanks for any help. Ryan

______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to