Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Inserting constant in select into

Author  Topic 

kaus
Posting Yak Master

179 Posts

Posted - 2002-07-26 : 14:29:58
Hi - I have a select into statement as follows:
IF EXISTS(
SELECT * FROM INFORMATION_SCHEMA.TABLES
WHERE table_name = 'MyTable' AND table_schema = 'GM')
BEGIN
drop table [MyTable]
END
Select
Proj_ID ID, Proj_Name Descr into MyTable
from dbo.Projects
where
Month_ID = 2 and
Man_ID = 5
Is there any way that I can insert another column into this table within this statement -- called 'Flag', and then populate it with a constant value -- say 'Project' ??

I'm going to do two more inserts after this one and want to set the flag for a different value on each of the inserts

Thanks

Pete

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-07-26 : 14:34:02
IF EXISTS(
SELECT * FROM INFORMATION_SCHEMA.TABLES
WHERE table_name = 'MyTable' AND table_schema = 'GM')
BEGIN
drop table [MyTable]
END
Select
Proj_ID ID, Proj_Name,'project' as flag, Descr into MyTable
from dbo.Projects
where
Month_ID = 2 and
Man_ID = 5


<O>

Edited by - Page47 on 07/26/2002 14:36:04
Go to Top of Page

kaus
Posting Yak Master

179 Posts

Posted - 2002-07-26 : 14:45:00
wow - not much to that -- I was trying an alter table

thanks



Go to Top of Page

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-07-26 : 14:47:05
Gimme a minute, I can make it more complicated for you ...

<O>
Go to Top of Page
   

- Advertisement -