Posted on: 10/29/2012 1:24:19 AM | Views : 245

create PROCEDURE searchuserdetail
@EndUser INT,
@AdminUser INT
AS
DECLARE @ErrorMessage AS VARCHAR(200)
BEGIN
BEGIN
SELECT A.[userid] ,
A.[username] ,
B.[userrole],
B.[BILLING_GRP_CD] AS BillingGroupCd
FROM [dbo].USERDETAIL AS A
INNER JOIN A.USERROLE AS B
ON [A].[USERID] = .[USERID]
WHERE [A].[ACTIVE] = 1
AND .[ROLEID] IN ( @Enduser ,
@Adminuser )
END

this sp gets the user information from the two tables userrole and userdetail .
Now in this SP temporary table is created and data from the XML is inserted into the table using SP_XML_PREPAREDOCUMENT
Temporary table has three column that are fieldName ,fieldvalue and operator.Blank Data table is returned and that sql query is stored in variable in order to use this dynamically . No of record from the temptable is counted and stored in a variable . Using while loop combination of field, value and oprat ...

Go to the complete details ...