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)
 inserting data to 1-column-table

Author  Topic 

katarina07
Starting Member

31 Posts

Posted - 2005-11-03 : 08:21:53
Hi, this is an "amateur" question for sure, I just need to solve it quickly.
I need to input data into 1-column-table like this:

declare @TMP_01 table ( Produkt varchar(45))

Insert into @TMP_01 (Produkt) VALUES ('241 class')
Insert into @TMP_01 (Produkt) VALUES ('241 class fees')
Insert into @TMP_01 (Produkt) VALUES ('241 class interest')
Insert into @TMP_01 (Produkt) VALUES ('242 class')
Insert into @TMP_01 (Produkt) VALUES ('242 class fees')
Insert into @TMP_01 (Produkt) VALUES ('242 class interest')
Insert into @TMP_01 (Produkt) VALUES ('243 class')
Insert into @TMP_01 (Produkt) VALUES ('243 class fees')
Insert into @TMP_01 (Produkt) VALUES ('243 class interest')
Insert into @TMP_01 (Produkt) VALUES ('248 classified')
Insert into @TMP_01 (Produkt) VALUES ('288 classified')
Insert into @TMP_01 (Produkt) VALUES ('288 classified interest)

Is there a more intelligent way to do it?
Something like:
Insert into @TMP_01 (Produkt) VALUES (value1 to row1, value2 to row2, etc.)

Thanks, Katarina

nr
SQLTeam MVY

12543 Posts

Posted - 2005-11-03 : 08:24:45
Not really - you could use a union to do it in a single statement but it's not any quicker to code.


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

katarina07
Starting Member

31 Posts

Posted - 2005-11-03 : 08:26:18
how would it look like with union?
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2005-11-03 : 08:57:16

Insert into @TMP_01 (Produkt)
select '241 class' union all
select '241 class fees' union all
select '241 class interest' union all
select '242 class' union all
select '242 class fees' union all
select '242 class interest' union all
select '243 class' union all
select '243 class fees' union all
select '243 class interest' union all
select '248 classified' union all
select '288 classified' union all
select '288 classified'

CODO ERGO SUM
Go to Top of Page
   

- Advertisement -