评论会员:游客 时间:2012/02/04
{C}imgsrc={A}]
baisak:选择使用加入记录和翻查参数,可以使用'中'。下面是从多个记录和搜索paremeters的检索记录的例子是用逗号隔开。
存储过程:
SELECT
ac.account_id AS [TPCompanyId],
ac.account_name AS [CompanyName],
[dbo].fn_get_address_forXML(ac.primary_address_id, @pi_user_id) as [address],
CASE WHEN LEN(ac.main_phone_extension)>0 THEN
CASE WHEN LEN(ac.main_phone) = 10 THEN
[dbo].fn_get_phone_format(ac.main_phone) +' x '+ ac.main_phone_extension ELSE
ac.main_phone + ' x ' + ac.main_phone_extension END
ELSE CASE WHEN len(ac.main_phone) = 10 THEN
[dbo].fn_get_phone_format(ac.main_phone) ELSE
ac.main_phone END end AS [Phone],
ac.email_id AS [Email],
ac.created_date as[CreatedDate]
FROM
[dbo].account ac
inner join [dbo].ref_account_type at On ac.account_type_id = at.account_type_id
and at.account_type_id = 2
and CASE WHEN @l_user_ch_provider_id is null THEN 1 ELSE ac.ch_provider_id END
= CASE WHEN @l_user_ch_provider_id is null THEN 1 ELSE @l_user_ch_provider_id END
and CASE WHEN @l_user_account_type_id is null or @l_user_account_type_id = 1 THEN 1 ELSE ac.account_id END
= CASE WHEN @l_user_account_type_id is null or @l_user_account_type_id = 1 THEN 1 ELSE @l_user_account_id END
LEFT JOIN [dbo].address ad ON ac.primary_address_id = ad.address_id
LEFT JOIN [dbo].contact ct ON ac.credit_processed_contact_id = ct.contact_id
LEFT JOIN [dbo].ref_city ci ON ad.city_id = ci.city_id
LEFT JOIN [dbo].ref_state st ON ad.state = st.state_id
LEFT JOIN [dbo].ref_credit_status cs ON ac.credit_status_id = cs.credit_status_id
LEFT JOIN [dbo].location lo ON ac.account_location_id = lo.location_id
LEFT JOIN [dbo].ref_account_status ras ON ras.account_status_id = ac.account_status_id
LEFT JOIN [dbo].contact cn ON ac.account_manager_id = cn.contact_id
WHERE ISNULL(ac.account_market_id, 0) IN (SELECT market_id FROM @tblMarkets)
在上面的例子market_id是搜索参数。请仔细去通过这个存储过程。如果我理解你的问题,正确的,然后它必须帮助你,否则精确您的问题
评论会员:游客 时间:2012/02/04
|digimanus:您好亲爱的,NBSP你要分离的表名和ID存储在一个临时表。然后遍历该表的记录,以获得您想要的记录。临时表应该包含minId和maxId循环NBSP通过记录;虽然(MinIdlt;MaxId)开始选择*从表LT;表临时tablegt的名称;LT你conditiongt;以上是简单exmaple无需使用任何连接所有reocrds。如果你想加入的表和记录,然后它会不会在这种情况下worthful.Soü有tonbsp的;得到所有的表名,并加入他们的行列根据您conditonwihtout循环通过每个table.nbsp;循环的方式通过记录,你可以使用光标。但它是不可靠,如临时表。使用临时表的存储过程的性能比光标:baisak:请添加一些更多的细节,以了解您的问题:YogeshPednekar
你好,
内的存储过程,首先得到所有的表根据您的IDS命名。然后加入,以获得所需的记录表
评论会员:baisak 时间:2012/02/04
您好亲爱的,
不ü有任何一种cotains所有现有的表的名称与IDS数据库中的表。如果是的话,那么在存储过程中先拆表ID','。因此,许多功能是可用的,这将分开的整个字符串","给你一个表,其中包含IDS wihtout任何comma.Then,试图从基表,其中包含所有随着names.nbsp的IDS表名; 现在你可以加入表得到所需的记录。| baisak:很不错的文章
-----------------------------
沙基尔伊克巴尔
------------------------------