Picking a column from a result set in the stored procedure? Sorry but I don't think so. But you can use a UDF that will return a result set, and from that UDF result set you can used a where clause to meet your needs. Sample...CREATE FUNCTION dbo.fnCompanyLedger( @From as datetime,@To as datetime,@CompanyID as numeric(18,0)) RETURNS @List TABLE ( Id int identity(1,1), col1 varchar(200), col2 varchar(200), col3 varchar(200), col4 varchar(200), col5 varchar(200), col6 varchar(200), trans7 varchar(200), trans8 varchar(200), trans9 varchar(200), trans10 varchar(200), trans11 varchar(200), trans12 varchar(200), trans13 varchar(200), trans14 varchar(200), transID as numeric(18), CompanyID as numeric(18))BEGINinsert into @List (col1, col2, col3, col4, col5, col16, trans7, trans8, trans9, trans10, trans11, trans12, trans13, trans14, transID, CompanyID)select t1.col1 ,t2.col2 ,t3.col2 ,t4.col2 ,t5.col2 ,t6.col2 ,t.trans7, t.trans8, t.trans9, t.trans10, ,t.trans11, t.trans12, t.trans13, t.trans14, transID, t.CompanyID from tbltransactions as tleft join tbl1 as t1 on t1.id = t.idleft join tbl2 as t2 on t2.id = t1.idleft join tbl3 as t3 on t3.id = t1.idleft join tbl4 as t4 on t4.id = t.idleft join tbl5 as t5 on t5.id = t.idleft join tbl6 as t6 on t6.id = t.idWHERE dtFrom >= @From and dtTo <= @To and CompanyID = @CompanyIDRETURNEND
Sample used...select tbl.col1from dbo.fnCompanyLedger('11/20/2007','11/22/2007') as tblwhere tbl.transID = 234
For fast result follow this...http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxWant Philippines to become 1st World COuntry? Go for World War 3...