[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 7247 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 90 days
Recommended Popular Threads Controvertial Threads
Conservative discussions
TPS for Nepal likely to extend next week
सालीको चाक
TPS for Venezuela is terminated, only 60 days extension for transition period
Venezuela TPS lawuit
Homeland Security revokes temporary status for 532,000 Cubans, Haitians, Nicaraguans and Venezuelans
I hope all the fake Nepali refugee get deported
Best Consultancy for H1 sponsorship in USA.
Trump admin revokes 18 months TPS extension for Venezuelans
What is the purpose of an F1 student visa in the U.S.?
#MAGA#FAFO is delicious
महँगो अण्डाको पिकल्प : कुखुरा र खोर भाडामा लिने
Homeowner Charged renting to illegal migrants
Measles vax deaths vs measles death in USA
Why some Nepali people pull each other's legs???
Please ask KRISTI NOEM in her facebook and other social media to renew TPS
US citizen Petitioning my wife who was out of status when she was in H1B. What to do ?
Travelling to Nepal with expiration less than 6 months
ICE kidnapping people off the streets over op eds
Don’t Just Read—Join the Conversation
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