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
 deleting rows from a temp table

Author  Topic 

godspeedba
Yak Posting Veteran

90 Posts

Posted - 2008-11-26 : 10:01:56
This is what I have done so far and fails dramatically with Invalid object name 't'.

I tried putting @table t but SQL hates this naming convention and wont let me save it. Any help would be appreciated

CREATE PROCEDURE sp_prop_nomain_photo AS
declare @table table(propertyid int)

Insert into @table
SELECT distinct propertyid
from tb_photos as t

DELETE FROM t
WHERE t.propertyid = tb_photos.propertyid AND tb_photos.main_photo = 1

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-11-26 : 10:04:40
[code]Delete t
from @table t join tb_photos p
on t.propertyid = p.propertyid
where p.main_photo = 1[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

godspeedba
Yak Posting Veteran

90 Posts

Posted - 2008-11-26 : 10:12:26
thank you :)
Go to Top of Page
   

- Advertisement -