[Show all top banners]

manvi
Replies to this thread:

More by manvi
What people are reading
Subscribers
:: Subscribe
Back to: Kurakani General Refresh page to view new replies
 SQL Help Urgent
[VIEWED 5510 TIMES]
SAVE! for ease of future access.
Posted on 05-02-07 12:44 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

I just need a simple store procedure which deletes a record from 2 tables. The second delete is comparing file_name field. What is the correct syntax for the second delete statement. Any help will be much appreciated. Thanks.

CREATE procedure up_test_delete(
@test_id int
)
as
delete from tests where test_id=@test_id
delete from (another table) where file_name ='filename.aspx?test_id='+@test_id
GO
 
Posted on 05-02-07 1:06 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

what do u mean by comparing filename field? did u mean to compare filename field with test_id? Please give good description about what is file type and test_id and how they are related. Then I can help you.
 
Posted on 05-02-07 1:22 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

file_name is a field in the second table. content of the file_name is like something.aspx?test_id=1 (@test_id)

where @test_id is the test_id value from first table.
 
Posted on 05-02-07 1:24 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

यसो गर्‍यो भने के हुन्छ ?

CREATE PROCEDURE up_test_delete
@test_id int
AS
BEGIN
DELETE FROM tests
WHERE tests.test_id= @test_id;
DELETE FROM otherTable
WHERE otherTable.file_name = @test_id;

END
GO
 
Posted on 05-02-07 1:28 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

But file_name has "something.aspx?test_id=" too.
 
Posted on 05-02-07 1:47 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

What is the problem you are getting with this?
delete from (another table) where file_name ='filename.aspx?test_id='+@test_id

maybe try
delete from (another table) where file_name ='filename.aspx?test_id='+ convert(varchar(40),@test_id)

Something like this
 
Posted on 05-02-07 2:46 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

how about trying below thing ?

CREATE PROCEDURE up_test_delete (test_id in varchar)
AS
BEGIN
DELETE FROM tests
WHERE tests.test_id= 'up_test_delete.test_id';
DELETE FROM otherTable
WHERE otherTable.file_name like '%up_test_delete.test_id%';
END;
/
 
Posted on 05-02-07 2:54 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

visit:
www.sqlserverperformance.com
www.microsoft.com/sql
www.umachandar.com
 
Posted on 05-11-07 8:00 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

I figured that it is not possible to do what I was trying to do using Store Porcedure so I had to write the function in the code page itself.

Thanks all for your help. :)
 
Posted on 05-11-07 8:03 PM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

its very possible. do this, it might work

CREATE procedure up_test_delete(
@test_id int
)
as
delete from tests where test_id=@test_id
delete from (another table) where file_name ='filename.aspx?test_id=' + cast(@test_id, varchar(10))
GO

- just a thought!
 
Posted on 05-12-07 1:13 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Hyaa, you are right as per my thought. Here is my SP:

CREATE procedure up_test_delete(
@test_id int
)
as
delete from tests where test_id=@test_id
delete from (another table) where file_name =’filename.aspx?test_id=’+CAST(@test_id AS VARCHAR(100)

Let me know if it helps you .

Regards
 


Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 200 days
Recommended Popular Threads Controvertial Threads
शीर्षक जे पनि हुन सक्छ।
NRN card pros and cons?
What are your first memories of when Nepal Television Began?
TPS Re-registration
TPS Re-registration case still pending ..
Democrats are so sure Trump will win
Basnet or Basnyat ??
nrn citizenship
Sajha has turned into MAGATs nest
Nas and The Bokas: Coming to a Night Club near you
ChatSansar.com Naya Nepal Chat
डीभी परेन भने खुसि हुनु होस् ! अमेरिकामाधेरै का श्रीमती अर्कैसँग पोइला गएका छन् !
3 most corrupt politicians in the world
अमेरिकामा बस्ने प्राय जस्तो नेपालीहरु सबै मध्यम बर्गीय अथवा माथि (higher than middle class)
if you are in USA illegally and ask for asylum it is legal
Travelling to Nepal - TPS AP- PASSPORT
Top 10 Anti-vaxxers Who Got Owned by COVID
आज बाट तिहारको सेल सकियो
निगुरो थाहा छ ??
ढ्याउ गर्दा दसैँको खसी गनाउच
Nas and The Bokas: Coming to a Night Club near you
Mr. Dipak Gyawali-ji Talk is Cheap. US sends $ 200 million to Nepal every year.
TPS Update : Jajarkot earthquake
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters