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 |
divyaaga
Starting Member
1 Post |
Posted - 2009-01-27 : 01:42:52
|
Hi ,I.m uploading 4 reports on the bases of 4 parameters.1.date2.report type: A,T,M,C3.Camp:1,2,3,44.EINCREATE PROC [dbo].[ABS]@REPORTTYPE NVARCHAR(1),@ABS BIGINT ASSET NOCOUNT ONIF @REPORTTYPE='A'BEGINSELECT ABS from Database1.dbo.table1 where ABS=@ABSENDELSE IF @REPORTTYPE='T' --will return multiple valuesBEGINSELECT ABS from Database1.dbo.table1 where ABS=@ABSENDELSE IF @REPORTTYPE='M'--will return multiple valuesBEGINSELECT ABS from Database1.dbo.table1 where ABS=@ABSENDELSE IF @REPORTTYPE='C'--will return multiple valuesBEGINSELECT ABS from Database1.dbo.table1 where ABS=@ABSEND-------------------------Then i'm calling according to ABS this stored procedure to another one.CREATE PROC [dbo].[Main]@ABS BIGINT,@Fromdate DATETIME,@Todate DATETIME,@CAMP BIGINT,@REPORTTYPE Char(1)ASSET NOCOUNT ONBEGINselect 'UserName'=(Select A.FirstName+' '+A.LastName from Database1.dbo.table1), SUM(CASE WHEN TYPE='T' THEN [ABC] ELSE 0 END) 'Tanu', 'T1'=(select Sum(B.Address) from Database2.dbo.table1), 'T2'=(select Sum(C.Address) from Database2.dbo.table2), 'T3'=(select Sum(D.Address) from Database2.dbo.table3), 'T4'=(select Sum(E.Address) from Database2.dbo.table4), FROM Database2.dbo.table5 LEFT JOIN database1.dbo.table1 AS A ON Database2.dbo.table5.ABS=A.ABSLEFT JOIN database2.dbo.table1 AS B ON Database2.dbo.table5.ABS=B.ABSLEFT JOIN database2.dbo.table2 AS C ON Database2.dbo.table5.ABS=C.ABSLEFT JOIN database2.dbo.table3 AS D ON Database2.dbo.table5.ABS=D.ABSLEFT JOIN database2.dbo.table4 AS E ON Database2.dbo.table5.ABS=E.ABSwhere Database2.dbo.table5.ABS IN(Database2.dbo.ABS(@REPORTTYPE,@ABS))AND Dated Between @Fromdate and @TodateAND Camp=@CAMPgroup by ABS-------------------------------------------------Please correct me . I'm not getting the data. |
|
heavymind
Posting Yak Master
115 Posts |
Posted - 2009-01-27 : 08:19:20
|
Only glanced the first part IF @REPORTTYPE='A'BEGINSELECTABSfrom Database1.dbo.table1where ABS=@ABSENDELSE IF @REPORTTYPE='T' --will return multiple valuesBEGINSELECTABSfrom Database1.dbo.table1where ABS=@ABSENDELSE IF @REPORTTYPE='M'--will return multiple valuesBEGINSELECTABSfrom Database1.dbo.table1where ABS=@ABSENDELSE IF @REPORTTYPE='C'--will return multiple valuesBEGINSELECTABSfrom Database1.dbo.table1where ABS=@ABSENDwhich is a bit redundant - all the ifs do the same....Thanks, VadymMCITP DBA 2005/2008Chief DBA at http://www.db-staff.com |
|
|
|
|
|
|
|