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
 General SQL Server Forums
 New to SQL Server Programming
 GETTING ALL DATA

Author  Topic 

Limuh
Yak Posting Veteran

94 Posts

Posted - 2008-04-17 : 00:03:27
SELECT @tempcc = CostCenterNbr FROM Tbl_People

I try to get all the data in the Table. but i only get the last data in the row. All i want is to get all the data from first to last. please help thank you.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-17 : 00:11:54
SELECT * INTO #Temp FROM Tbl_People
gets all data from your table to temporary table
You can store only one value in a variable. Thats why it stores and gives you last value when you do assignment as above.
Go to Top of Page

Limuh
Yak Posting Veteran

94 Posts

Posted - 2008-04-17 : 02:15:30
let me clear up the problem sorry.
im making a stored procedure. i have a table1 where i get the phone number and insert that phone number to the other table2. The problem of my query is that it only inserted the last phonenumber to table@ and i want all the phone number will be inserted to the table. Please help.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-17 : 03:01:08
UPDATE t2
SET t2.phonenumber=t1.phonenumber
FROM table2 t2
INNER JOIN table1 t1
ON t1.commoncol=t2.commoncol
Go to Top of Page
   

- Advertisement -