• CRM 常用SQL 脚本


    1. 查询角色、用户

    SELECT DISTINCT DomainName,
            u.FullName ,
            u.FirstName,
            u.InternalEMailAddress,
            r.Name,
            r.BusinessUnitIdName
    FROM    SystemUser u
            JOIN systemuserroles ur ON u.SystemUserId = ur.SystemUserId
            JOIN Role r ON ur.RoleId = r.RoleId
            ORDER BY u.FullName

    2. 审批流结点查询

            --审批模板
            SELECT  crm_default_flag ,
                    crm_entity_name ,
                    crm_approve_templeteId ,
                    createdon ,
                    crm_name ,
                    crm_subject_field ,
                    crm_wf_instanceid_field ,
                    *
            FROM    crm_approve_templete
            WHERE   crm_approve_templeteId IN (
                    '5B95D67C-A860-E411-9417-005056B01E9A',
                    '5F95D67C-A860-E411-9417-005056B01E9A' )

    --审批流程模板节点
            SELECT  crm_approver ,
                    crm_wf_templete_nodeid ,
                    crm_name ,
                    a.crm_node_class ,
                    b.Value ,
                    crm_node_type ,
                    crm_security_role '审批角色' ,
                    crm_approver '审批人' ,
                    CreatedOn ,
                    crm_security_roleName ,
                    crm_submit_busunitid ,
                    *
            FROM    crm_wf_templete_node a ,
                    StringMap b
            WHERE   a.crm_node_class = b.AttributeValue
                    AND b.AttributeName = 'crm_node_class'
                    AND crm_approve_templete_id IN (
                    '5B95D67C-A860-E411-9417-005056B01E9A',
                    '5F95D67C-A860-E411-9417-005056B01E9A' )

    3. 报表

    DECLARE @binUserGuid VARBINARY(128)

    DECLARE @userGuid UNIQUEIDENTIFIER
    SELECT @userGuid = ( SELECT TOP 1
                                   SystemUserId
                         FROM      SystemUser
                         WHERE     DomainName = 'tct-hqcrmtadmin'
                       )
    SET @binUserGuid = CAST(@userGuid AS VARBINARY(128))
    SET context_info @binUserGuid

    4. RC

    SELECT  new_soldtoid, new_incotermid, u.SystemUserId, u.FullName FROM new_soldto s
    JOIN new_rc r ON s.new_sap_code = r.new_sap_code
    JOIN dbo.BusinessUnit b ON r.new_rcId = b.new_rc
    JOIN dbo.SystemUser u ON b.BusinessUnitId = u.BusinessUnitId
    WHERE u.SystemUserId ='424E63B8-1B16-E411-93F7-0050568F4CCE'

  • 相关阅读:
    SQL Server存储过程
    数据访问模式:数据并发控制(Data Concurrency Control)
    C#设计模式系列:观察者模式(Observer)
    awk内置字符串函数 awk 格式化输出
    使用MegaCli和Smartctl获取普通磁盘
    Shell之date用法
    linux 系统下查看raid信息,以及磁盘信息
    linux下proc里关于磁盘性能的参数
    hdparm测试硬盘性能
    查看现有运行的linux服务器有多少内存条
  • 原文地址:https://www.cnblogs.com/fengwenit/p/4098360.html
走看看 - 开发者的网上家园