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.
| Author |
Topic |
|
soorajtnpki
Posting Yak Master
231 Posts |
Posted - 2008-11-12 : 00:40:10
|
| hi experts, i want to build a procedure that bring data from different tables like belowCREATE PROCEDURE [dbo].usp_name( declarations)ASBEGINset no count onselect data1 from table1 where conditionsend BEGINset no count onselect data1,data6 from table2 where conditionsend BEGINset no count onselect data1,data7 from table3 where conditionsend BEGINset no count onselect data1 from table4 where conditionsend is it necessary to put begin end for each select queries..or can i club them in a single begin end |
|
|
malaytech2008
Yak Posting Veteran
95 Posts |
Posted - 2008-11-12 : 00:44:48
|
| This is sufficient..CREATE PROCEDURE [dbo].usp_name(declarations)ASBEGINset no count onselect data1 from table1 where conditionsselect data1,data6 from table2 where conditionsselect data1,data7 from table3 where conditionsselect data1 from table4 where conditionsend malay |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-12 : 00:47:11
|
| unless you've some IF ELSE condition checks for each selects you need only a single begin end. But just in case what you're trying is to return different result sets for different conditions you need seperate BEGIN ENDs... |
 |
|
|
malaytech2008
Yak Posting Veteran
95 Posts |
Posted - 2008-11-12 : 01:01:16
|
| thats right.only for block condition. we need BEGIN and ENDmalay |
 |
|
|
soorajtnpki
Posting Yak Master
231 Posts |
Posted - 2008-11-12 : 01:03:05
|
| i want all select queries to return data at all times..ie all queries should return at all times |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-12 : 01:04:38
|
quote: Originally posted by soorajtnpki i want all select queries to return data at all times..ie all queries should return at all times
then what malay posted is sufficient |
 |
|
|
|
|
|