all groups > sql server mseq > october 2003 >
You're in the

sql server mseq

group:

INSERT , SELECT and UPDATE


INSERT , SELECT and UPDATE Vina
10/6/2003 11:08:18 AM
sql server mseq:
I have a sql statement
Insert Into testtable (IT) Select ITEM AS IT from
TableName
I would like to add a field in the Test table the
TableName for every record. Can someone give me an idea
on how the syntax be?

The situation is the TableName is changing so I want to
have a field in my Testtable to know where this Items
came from, from which table.

Thanks
Re: INSERT , SELECT and UPDATE Vishal Parkar
10/6/2003 11:36:54 AM
you will have to hardcode the value for tablename in the
INSERT INTO...SELECT statement as follows.

Ex:
create table testtable (tbname varchar(500), it int)

insert into testtable(tbname, it)
select 'tablename', item as it from tablename

--in above example 'tablename' value is hardcoded.

Re: INSERT , SELECT and UPDATE Vina
10/7/2003 5:48:04 AM
Thanks for this idead, found a way to get my statement to
work
[quoted text, click to view]
AddThis Social Bookmark Button