load data from XML to SQL using SP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kumarlalit
    New Member
    • Oct 2012
    • 5

    load data from XML to SQL using SP

    Hi,

    I had created the following SP , now in this sp i am unable to do this , pls help me to do this

    Code:
    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] = [B].[USERID]
                      WHERE     [A].[ACTIVE] = 1
     AND  [B].[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_PREPARED OCUMENT
    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 oprator is applied to the where condition in sql Query

    Code:
    Column name  
    
    
    userid            userid maps to the tablemasterid 
    username          username maps to the table tablemasterid table 
    Status            it is the status of the user that maps to from tablemasterid



    tablemasterid has following coloumn

    Code:
    userid      username  useraddress      Status 
    
    1           abcd      address1          1 
    2           ghuj      address2          0
    Last edited by Rabbit; Oct 27 '12, 11:48 PM. Reason: Please use code tags when posting code.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You explained what you're doing with your code but you haven't explained what your question is.

    Comment

    • Kumarlalit
      New Member
      • Oct 2012
      • 5

      #3
      My question is load the data from xml using temp table into sql server table as pls see the question everthing is explained

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        I've read your post. But you explain nothing about your question. You said you used SP_XML_PREPARED OCUMENT in your stored procedure but it's no where in your stored procedure.

        Comment

        Working...