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
 Transact-SQL (2000)
 Is it possible to do an Insert All?

Author  Topic 

chriskhan2000
Aged Yak Warrior

544 Posts

Posted - 2005-03-09 : 14:28:51
I have this table that I want to do an insert all without having to define the field. Is it possible to do this?

INSERT * INTO Sales
WHERE ID = '012322'

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-03-09 : 14:33:35
what do you mean exactly?
and getting all of the fields in a table isn't that hard:

Declare @ColumnList varchar(1000)
SELECT @ColumnList = COALESCE(@ColumnList + ', ', '') + column_name
FROM INFORMATION_SCHEMA.Columns
WHERE table_name = 'TableName'
select @ColumnList


Go with the flow & have fun! Else fight the flow
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-03-09 : 14:35:35
INSERT INTO SALES
SELECT * FROM SomeTable WHERE...

But I don't recommend it....



Brett

8-)
Go to Top of Page

chriskhan2000
Aged Yak Warrior

544 Posts

Posted - 2005-03-09 : 14:50:16
Thanks you both. Being a newbie is quite hard, but for you gurus it's a piece of cake. hehe.

Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-03-09 : 14:56:25
brett doesn't recomend it because your data might not get inserted into proper columns.
it depends on the ordinal position of the column in a table.

Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -