[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 6318 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
TPS Re-registration case still pending ..
Anybody gotten the TPS EAD extension alert notice (i797) thing? online or via post?
TPS EAD auto extended to June 2025 or just TPS?
Toilet paper or water?
ढ्याउ गर्दा दसैँको खसी गनाउच
Mamta kafle bhatt is still missing
ChatSansar.com Naya Nepal Chat
whats wrong living with your parents ?
TPS advance parole Travel document i-131, Class of Admission ?
Tourist Visa - Seeking Suggestions and Guidance
Now Trump is a convicted criminal .
Ajay Kumar Dev sentenced to 378 yrs
Biden said he will issue new Employment visa for someone with college degree and job offers
Why Americans reverse park?
Problems of Nepalese students in US
Nepali Passport Renewal
lost $3500 on penny stocks !!!
Biden out, Trump next president, so what’s gonna happen to TPS, termination?
They are openly permitting undocumented immigrants to participate in federal elections in Arizona now.
Are Nepalese cheapstakes?
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