select tsm.TMsgID,tsm.TMID,tsm.FNRID,tm.MainComID, tsm.TMsgName,fb.FBDataTbale, tsm.REMARK,fb.FlowType, tsm.CreateTime, fb.FBID,tsm.BranchID from TTransMessage as tsm
left join TTransMain as tm on tsm.TMID = tm.TMID
left join TFlowBase fb on tm.FBID = fb.FBID
where tsm.TMsgState =0 and tsm.RecvUser = 1400

exec sp_executesql N'SELECT [tm].[MainComID], [n].[TMsgID], [n].[TMID], [n].[FNRID], CONVERT(int, CONVERT(int, [tm].[MainComID])) AS [MainComID], [n].[TMsgName], [t1].[Item_no], [t1].[Contract_i_no], [t4].[CompanyName], [t5].[CustomerName], [t1].[Pro_name], [t1].[Pro_model], [t1].[Plat_number], [t6].[AreaName] AS [regionName], [t7].[AreaName], [n].[CreateTime], [t3].[FNStateName], [t1].[Contract_o_no], [t1].[Delivered_time], [n].[REMARK], [t1].[Project_name], CASE
WHEN [n].[EWFlag] IS NULL
THEN N'''' ELSE [n].[EWFlag]
END AS [EWFlag], [t1].[rowguid] AS [OrderID], [t5].[CusClassifyName], [t].[FBDataTbale]
FROM [TTransMessage] AS [n]
LEFT JOIN [TTransMain] AS [tm] ON [n].[TMID] = [tm].[TMID]
LEFT JOIN (
SELECT [n0].*
FROM [TFlowBase] AS [n0]
WHERE ([n0].[DELETE_FLAG] <> 1) OR [n0].[DELETE_FLAG] IS NULL
) AS [t] ON [tm].[FBID] = [t].[FBID]
LEFT JOIN (
SELECT [n1].*
FROM [SFSaleAfter] AS [n1]
WHERE ([n1].[DELETE_FLAG] <> N''1'') OR [n1].[DELETE_FLAG] IS NULL
) AS [t0] ON CONVERT(int, [tm].[MainComID]) = [t0].[SaleAfterID]
LEFT JOIN (
SELECT [n2].*
FROM [TOrders] AS [n2]
WHERE ([n2].[DELETE_FLAG] <> N''1'') OR [n2].[DELETE_FLAG] IS NULL
) AS [t1] ON [t0].[TOrderID] = [t1].[rowguid]
LEFT JOIN (
SELECT [n3].*
FROM [TFlowNodeRoperty] AS [n3]
WHERE ([n3].[DELETE_FLAG] <> 1) OR [n3].[DELETE_FLAG] IS NULL
) AS [t2] ON [n].[FNRID] = [t2].[FNRID]
LEFT JOIN (
SELECT [n4].*
FROM [TFlowNodes] AS [n4]
WHERE ([n4].[DELETE_FLAG] <> 1) OR [n4].[DELETE_FLAG] IS NULL
) AS [t3] ON [t2].[FNID] = [t3].[FNID]
LEFT JOIN (
SELECT [n5].*
FROM [TCompany] AS [n5]
WHERE ([n5].[DELETE_FLAG] <> 1) OR [n5].[DELETE_FLAG] IS NULL
) AS [t4] ON [t1].[Produce_company] = [t4].[CompanyID]
LEFT JOIN (
SELECT [n6].*
FROM [Customer] AS [n6]
WHERE ([n6].[DELETE_FLAG] <> N''1'') OR [n6].[DELETE_FLAG] IS NULL
) AS [t5] ON [t1].[Custom_no] = [t5].[CustomerID]
LEFT JOIN (
SELECT [n7].*
FROM [PubArea] AS [n7]
WHERE ([n7].[DELETE_FLAG] <> N''1'') OR [n7].[DELETE_FLAG] IS NULL
) AS [t6] ON [t1].[Slice_no] = [t6].[AreaID]
LEFT JOIN (
SELECT [n8].*
FROM [PubArea] AS [n8]
WHERE ([n8].[DELETE_FLAG] <> N''1'') OR [n8].[DELETE_FLAG] IS NULL
) AS [t7] ON [t1].[Area_no] = [t7].[AreaID]
WHERE ((([n].[DELETE_FLAG] <> N''1'') OR [n].[DELETE_FLAG] IS NULL) AND (([n].[TMsgState] = 0) AND ([n].[RecvUser] = @__UserInfo_ROWGUID_0))) AND ((([t1].[Order_type] = N''2'') OR ([t].[FBID] = 38)) AND ([t].[FBDataTbale] = N''SFSaleAfter''))',N'@__UserInfo_ROWGUID_0 int',@__UserInfo_ROWGUID_0=1400

待办消息查询sql的更多相关文章

  1. 金蝶k/3 K3云之家消息查询发送是否成功SQL语句

    金蝶k/3 K3云之家消息查询发送是否成功SQL语句 1是成功,0是还在轮询中未发送,4是发送失败 select * into #tempUserID from ( union select t_Gr ...

  2. activiti工作流已办和待办查询sql

    最近项目中遇到一个问题,需要activiti的工作流表和业务表关联分页查询,然而我对于工作流的查询并不太熟悉,所以学习并总结如下. 想看看activiti到底怎么查询的待认领和待办.已办的查询sql, ...

  3. 面试官:说说一条查询sql的执行流程和底层原理?

    一条查询SQL执行流程图如下 序章 自我介绍 我是一条sql,就是一条长长的字符串,不要问我长什么样,因为我比较傲娇. 额~~不是我不说啊,因为细说起来,我可以细分为DML(Update.Insert ...

  4. 多表查询sql语句

    多表查询sql语句 1 --解锁SCOTT用户 2 alter user scott account unlock 3 --检索指定的列 4 select job,ename,empno from e ...

  5. MySQL - 常用命令及常用查询SQL

    常用查询SQL #查看临时目录 SHOW VARIABLES LIKE '%tmp%'; #查看当前版本 SELECT VERSION(); 常用命令 #查看当前版本,终端下未进入mysql mysq ...

  6. 【ORACLE】记录通过执行Oracle的执行计划查询SQL脚本中的效率问题

    记录通过执行Oracle的执行计划查询SQL脚本中的效率问题   问题现象: STARiBOSS5.8.1R2版本中,河北对帐JOB执行时,无法生成发票对帐文件.   首先,Quartz表达式培植的启 ...

  7. 查询sql语句所花时间

    --1:下面这种是SQL Server中比较简单的查询SQL语句执行时间方法,通过查询前的时间和查询后的时间差来计算的: declare @begin_date datetime declare @e ...

  8. 跨服务器查询sql语句样例

    若2个数据库在同一台机器上:insert into DataBase_A..Table1(col1,col2,col3----)select col11,col22,col33-- from Data ...

  9. 查询sql表列名

    --查询sql 查询表列名Select Name FROM SysColumns Where id=Object_Id('Tab') --查询sql数据库表列名称select name from sy ...

随机推荐

  1. jmeter 后台运行 setsid bin/jmeter -n -t .jmx文件 -l .jtl文件

    备注: 另外,在Linux下我们有时候希望线程可以在后台运行,这样我们关闭当前连接后,线程依然可以运行,这里提供一个将 jmeter命令设置为后台线程的方法. 使用setsid命令:  setsid  ...

  2. Scrapy框架: 第一个程序

    首先创建项目: scrappy start project maitian 第二步: 明确要抓取的字段items.py import scrapy class MaitianItem(scrapy.I ...

  3. Python 常见报错类型

    一.TypeError:类型错误,对象用来表示值的类型非预期类型时发生的错误 错误例子: age=18 print(‘我的年龄是’+age) 报错信息:TypeError: can only conc ...

  4. 《linux 内核全然剖析》sched.c sched.h 代码分析笔记

    版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/u011368821/article/details/25129835 sched.c sched.h ...

  5. android中的BroadCastReceiver

    BroadCastReceiver组件本质是一种全局的监听器,用于监听系统全局的广播消息.由于BroadCastReceiver是一种全局的监听器,因此他可以非常方便的实现系统之间不同组件之间的通信. ...

  6. Spring Cloud服务保护

    微服务虽然解决了传统单体式应用各个模块之间强耦合的缺点,但同时也引出了新问题,由于微服务各个服务之间是独立部署的,并且一般情况下一个服务往往会依赖多个其他服务,并且服务之间的调用更多的是依赖不稳定的网 ...

  7. Windows虚拟机共享公司网络给Linux host

    前两天写了一个Linux主机通过windows虚拟机上网的随笔,实话说功能有点弱,比如22端口的转发都没有.实际上还有一个更简单且功能更强的共享方法(不需要安装ccproxy). https://ww ...

  8. redis底层相关命令(一)

    说明 用于分析redis底层数据结构以及内存情况 底层数据结构分析 1.查看key键的对象类型type key 本地:>sadd test1 本地:>type test1 set 2.查看 ...

  9. DLL 本地定义符号*****在函数****中导入

    把_DLL_ELOGEVENT  定义到你的工程预编译宏中 IPCLASSDLL_DLL https://bbs.csdn.net/topics/300140279

  10. app混合开发 fastlick.js 在ios上 input标签点击 不灵敏 处理

    ios11 上有这个问题 而老版本的ios没有 会出现这个的原因是使用fastclick.js点击后input没有获取焦点,所以只需要在fasyclick的源码的这个位置 可以直接在源码内搜索关键字找 ...