question

AmeshJeram avatar image
AmeshJeram asked

query in stored proc to findmatch

two databases, with two (should be same) tables. What I need is to declare a variable search in a sp to ask to enter a value then it queries and searches from DB1.T1 and DB2.T2 and output if 'matching' else value not available on DB2.T2
query
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
KenJ avatar image
KenJ answered
CREATE PROCEDURE dbo.your_search_procedure_name @variable_to_use_for_search varchar(MAX) AS IF EXISTS( SELECT * FROM DB1..T1 AS T1 INNER JOIN DB2..T2 AS T1 ON T1. = T2. WHERE T1. = @variable_to_use_for_search ) SELECT 'matching' AS result ELSE SELECT 'value not available' AS result
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

AmeshJeram avatar image AmeshJeram commented ·
Perfect, Thank you very much
0 Likes 0 ·
Grant Fritchey avatar image Grant Fritchey ♦♦ commented ·
If @KenJ has provided you with the answer @AmeshJeram you should indicate this by clicking on the thumbs up next to it to vote it up and clicking on the check box to mark it as the answer.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.