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 |
|
abcd
Yak Posting Veteran
92 Posts |
Posted - 2009-02-19 : 04:45:10
|
| hi all...I have two tables File and bookFormat for the tables is as follows..FOR FILE TABLE FileId ,CompanyId ,DeptId ,GroupId ,VoucherId ,YearId ,LocationId ,FileNo ,CreatedOn ,CreatedBy ,BookNo ,DescriptionFOR BOOK TABLE LabelId ,CompanyId ,DeptId ,GroupId ,LocationId ,VoucherId ,YearId ,FromDate ,ToDate ,VoucherSNo1 ,VoucherSNo2 ,BookNo ,CreatedOn ,CreatedBy ,DescriptionI want to make a procedure in which there are two parameters @locationid,@typeIf type is 'f' then i want to select full detail from file table else select detail from book table...Do suggest some way out... |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-02-19 : 04:50:52
|
| [code]create proc usp_samp(@locationid int,@type varchar(4))set nocount onif (@type ='f')select * from filetable where locationid = @locationidelseselect * from booktable where locationid = @locationidset nocount off[/code] |
 |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2009-02-19 : 05:00:18
|
quote: Originally posted by bklr
create proc usp_samp(@locationid int,@type varchar(4))set nocount onif (@type ='f')select * from filetable where locationid = @locationidelseselect * from booktable where locationid = @locationidset nocount off
Some corrections there,CREATE proc usp_samp (@locationid int,@type varchar(4)) asbeginset nocount onif (@type ='f')select * from filetable where locationid = @locationid elseselect * from booktable where locationid = @locationid set nocount offend |
 |
|
|
abcd
Yak Posting Veteran
92 Posts |
Posted - 2009-02-19 : 05:11:42
|
| hey saket a lot!!!!!:):)Ur query solved my problem.... |
 |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2009-02-19 : 05:27:03
|
| np |
 |
|
|
|
|
|
|
|