AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / dba / 问题

问题[datetime2](dba)

Martin Hope
NicolasGutierrezToD
Asked: 2019-08-30 17:33:00 +0800 CST

操作数类型冲突:int 与 datetime2 不兼容

  • -3

下面的代码会生成此错误:

错误

消息 206,级别 16,状态 2,过程 usp_TRAC_PSE_Step_12_Resource_Request_OBJECT-Production-Part1,第 93 行操作数类型冲突:int 与 datetime2 不兼容

代码
insert into [dbo].[pse__Resource_Request__c_LOAD]
    (OwnerId, pse__End_Date__c, pse__Milestone__c, pse__Percent_Allocated__c, pse__Planned_Bill_Rate__c,
     pse__Practice__c, pse__Project__c, pse__Region__c, pse__SOW_Hours__c, pse__Request_Priority__c,
     pse__Resource_Request_Name__c, pse__Resource_Role__c, pse__Start_Date__c, pse__Status__c,
     Partner_Requested__c, OA_Migration_ID__c, CurrencyIsoCode, Percent_Onsite__c)
    
    select (select [OwnerId] from [dbo].[pse__Proj__c_LOAD] where [OA_Migration_ID__c] = p.id) 'OwnerId'
          , case when case when p.custom_35 is null then ISNULL(b.startdate, '01/01/1900 23:59:59.999') + 180 else p.custom_35 end  <  ISNULL(b.startdate, '01/01/1900 23:59:59.999')  then  ISNULL(b.startdate, '01/01/1900 23:59:59.999') + 180 else case when p.custom_35 is null then ISNULL(b.startdate, '01/01/1900 23:59:59.999') + 180 else p.custom_35 end end 'pse__End_Date__c'
          , null 'pse__Milestone__c' -- Need to figure out how to link to a milestone
          , null 'pse__Percent_Allocated__c'  -- this data is not a percentage.... either remove or data needs to be fixed
          , null 'pse__Planned_Bill_Rate__c' -- Determine if we are loading anything here
          , 'a94300000008OQEAA2'  'pse__Practice__c'  --Not sure where i can get this... talk to xxxx
          , (select [id] from [dbo].[pse__Proj__c_LOAD] where [OA_Migration_ID__c] = p.id) 'pse__Project__c'
          , (select [pse__Region__c] from [dbo].[pse__Proj__c_LOAD] where [OA_Migration_ID__c] = p.id) 'pse__Region__c'
          , b.hours 'pse__SOW_Hours__c'
          , case when p.project_stage_id = 8 then 'High' else 'Normal' End  'pse__Request_Priority__c' -- this column does not exist in the booking table as noted in the mapping document b.priority
          , substring(b.name,0,255) 'pse__Resource_Request_Name__c'
          , case when b.job_code_id = 54 then 'MC - Account Director'
                    when b.job_code_id = 19 then 'MC - Account Director'
                    when b.job_code_id = 23 then 'MC - Technology Architect'
                    when b.job_code_id = 56 then 'MC - Analytics Consultant'
                    when b.job_code_id = 41 then 'MC - Campaign Manager'
                    when b.job_code_id = 21 then 'MC - Centric Development'
                    when b.job_code_id = 17 then 'MC - Client Training Specialist'
                    when b.job_code_id = 50 then 'MC - Designer'
                    when b.job_code_id = 22 then 'MC - Technology Architect'
                    when b.job_code_id = 36 then 'MC - Data Architect'
                    when b.job_code_id = 37 then 'MC - Data Architect'
                    when b.job_code_id = 55 then 'MC - Deliverability Consultant'
                    when b.job_code_id = 7 then 'MC - Deployment Specialist'
                    when b.job_code_id = 15 then 'MC - Designer'
                    when b.job_code_id = 27 then 'MC - Technology Architect'
                    when b.job_code_id = 45 then 'MC - Project Manager'
                    when b.job_code_id = 42 then 'MC - Project Manager'
                    when b.job_code_id = 44 then 'MC - Project Manager'
                    when b.job_code_id = 46 then 'MC - Project Manager'
                    when b.job_code_id = 49 then 'MC - Project Manager'
                    when b.job_code_id = 43 then 'MC - Project Manager'
                    when b.job_code_id = 11 then 'MC - Deployment Specialist'
                    when b.job_code_id = 10 then 'MC - Deployment Specialist'
                    when b.job_code_id = 20 then 'MC - Technology Architect'
                    when b.job_code_id = 25 then 'MC - Technology Architect'
                    when b.job_code_id = 18 then 'MC - Project Manager'
                    when b.job_code_id = 26 then 'MC - Marketing Consultant'
                    when b.job_code_id = 9 then 'MC - Marketing Consultant'
                    when b.job_code_id = 31 then 'MC - Deployment Specialist'
                    when b.job_code_id = 16 then 'MC - Deployment Specialist'
                    when b.job_code_id = 35 then 'MC - Project Manager'
                    when b.job_code_id = 53 then 'MC - Marketing Consultant'
                    when b.job_code_id = 39 then 'MC - Production Specialist'
                    when b.job_code_id = 5 then 'MC - Program Manager'
                    when b.job_code_id = 3 then 'MC - Program Manager'
                    when b.job_code_id = 4 then 'MC - Program Manager'
                    when b.job_code_id = 2 then 'MC - Project Manager'
                    when b.job_code_id = 1 then 'MC - Project Manager'
                    when b.job_code_id = 47 then 'MC - Deployment Specialist'
                    when b.job_code_id = 14 then 'MC - Designer'
                    when b.job_code_id = 8 then 'MC - Marketing Consultant'
                    when b.job_code_id = 48 then 'MC - Project Manager'
                    when b.job_code_id = 24 then 'MC - Project Manager'
                    when b.job_code_id = 38 then 'MC - Designer'
                    when b.job_code_id = 52 then 'MC - Marketing Consultant'
                    when b.job_code_id = 40 then 'MC - Solution Architect'
                    when b.job_code_id = 51 then 'MC - Project Manager'
                    when b.job_code_id = 6 then 'MC - Technical Producer'
                    when b.job_code_id = 57 then 'MC - Technical QA Specialist'
                    when b.job_code_id = 12 then 'MC - Technology Architect'
                    when b.job_code_id = 13 then 'MC - Technology Specialist'
                        else case when b.job_code_id = 0 then case when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 54 then 'MC - Account Director'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id) = 19 then 'MC - Account Director'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 23 then 'MC - Technology Architect'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 56 then 'MC - Analytics Consultant'
                    when(select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 41 then 'MC - Campaign Manager'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 21 then 'MC - Centric Development'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 17 then 'MC - Client Training Specialist'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 50 then 'MC - Designer'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 22 then 'MC - Technology Architect'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 36 then 'MC - Data Architect'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 37 then 'MC - Data Architect'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 55 then 'MC - Deliverability Consultant'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 7 then 'MC - Deployment Specialist'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 15 then 'MC - Designer'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 27 then 'MC - Technology Architect'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 45 then 'MC - Project Manager'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 42 then 'MC - Project Manager'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 44 then 'MC - Project Manager'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 46 then 'MC - Project Manager'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 49 then 'MC - Project Manager'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 43 then 'MC - Project Manager'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 11 then 'MC - Deployment Specialist'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 10 then 'MC - Deployment Specialist'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 20 then 'MC - Technology Architect'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 25 then 'MC - Technology Architect'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 18 then 'MC - Project Manager'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 26 then 'MC - Marketing Consultant'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 9 then 'MC - Marketing Consultant'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 31 then 'MC - Deployment Specialist'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 16 then 'MC - Deployment Specialist'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 35 then 'MC - Project Manager'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 53 then 'MC - Marketing Consultant'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 39 then 'MC - Production Specialist'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 5 then 'MC - Program Manager'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 3 then 'MC - Program Manager'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 4 then 'MC - Program Manager'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 2 then 'MC - Project Manager'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 1 then 'MC - Project Manager'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 47 then 'MC - Deployment Specialist'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 14 then 'MC - Designer'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 8 then 'MC - Marketing Consultant'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 48 then 'MC - Project Manager'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 24 then 'MC - Project Manager'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 38 then 'MC - Designer'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 52 then 'MC - Marketing Consultant'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 40 then 'MC - Solution Architect'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 51 then 'MC - Project Manager'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 6 then 'MC - Technical Producer'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 57 then 'MC - Technical QA Specialist'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 12 then 'MC - Technology Architect'
                    when (select job_code_id from OpenAir_user iu where iu.id = b.user_id)  = 13 then 'MC - Technology Specialist' end
                         else 'Undefined' end   End 'pse__Resource_Role__c' -- xxxxx is going to send me the mapping file to translate job code to Org62 values
        --  , null 'pse__Staffer_Approval_Required__c' -- need to determine if this is needed
          , b.startdate 'pse__Start_Date__c'
          , case when p.project_stage_id = 8 then 'Ready to Staff' else 'Assigned' End  'pse__Status__c'-- this column does not exist in the booking table as noted in the mapping document b.approval_Status
          , case when custom_64 ='Partner Requested' and p.project_stage_id in (8, 14) then 'true' else 'false' end 'Partner_Requested__c'
          , b.id 'OA_Migration_ID__c'
          , (select CurrencyIsoCode from [dbo].[pse__Proj__c_LOAD] where [OA_Migration_ID__c] = p.id)  'CurrencyIsoCode'
          , 0 'Percent_Onsite__c'
    from openair_integration.dbo.booking b,
         [dbo].[Migrated_Projects] mp,
         openair_integration.dbo.project p
    where b.project_id = mp.id
    and b.project_id = p.id
    and booking_type_id = 8
    --and b.custom_64 <> 'SOW Hours'
    and isnull(b.deleted,0) <> 1
    --and mp.stage = 'Active'
sql-server datetime2
  • 1 个回答
  • 15976 Views
Martin Hope
Docjay
Asked: 2014-04-25 11:25:37 +0800 CST

帮助处理超出范围的值

  • 2

我有这个查询给我一个错误

将 varchar 数据类型转换为 datetime 数据类型导致值超出范围。

询问:

select 
    COUNT(*) 
from 
    dbo.patient
INNER JOIN 
    dbo.study on dbo.patient.pk = dbo.study.patient_fk
              and dbo.study.study_datetime IS NOT NULL
              and dbo.patient.pat_birthdate IS NOT NULL
              and dbo.study.study_datetime <= DATEADD(D, -2192, GETDATE())
              and dbo.patient.pat_birthdate <= DATEADD(D, -7670, GETDATE());

我读到这可能有助于转换为“DATETIME2”,但我不太清楚如何正确转换列“s.study_datetime”,因为该列很可能有一些错误的值作为条目。

sql-server-2008-r2 datetime2
  • 1 个回答
  • 6070 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目

    • 12 个回答
  • Marko Smith

    如何让sqlplus的输出出现在一行中?

    • 3 个回答
  • Marko Smith

    选择具有最大日期或最晚日期的日期

    • 3 个回答
  • Marko Smith

    如何列出 PostgreSQL 中的所有模式?

    • 4 个回答
  • Marko Smith

    列出指定表的所有列

    • 5 个回答
  • Marko Smith

    如何在不修改我自己的 tnsnames.ora 的情况下使用 sqlplus 连接到位于另一台主机上的 Oracle 数据库

    • 4 个回答
  • Marko Smith

    你如何mysqldump特定的表?

    • 4 个回答
  • Marko Smith

    使用 psql 列出数据库权限

    • 10 个回答
  • Marko Smith

    如何从 PostgreSQL 中的选择查询中将值插入表中?

    • 4 个回答
  • Marko Smith

    如何使用 psql 列出所有数据库和表?

    • 7 个回答
  • Martin Hope
    Jin 连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目 2014-12-02 02:54:58 +0800 CST
  • Martin Hope
    Stéphane 如何列出 PostgreSQL 中的所有模式? 2013-04-16 11:19:16 +0800 CST
  • Martin Hope
    Mike Walsh 为什么事务日志不断增长或空间不足? 2012-12-05 18:11:22 +0800 CST
  • Martin Hope
    Stephane Rolland 列出指定表的所有列 2012-08-14 04:44:44 +0800 CST
  • Martin Hope
    haxney MySQL 能否合理地对数十亿行执行查询? 2012-07-03 11:36:13 +0800 CST
  • Martin Hope
    qazwsx 如何监控大型 .sql 文件的导入进度? 2012-05-03 08:54:41 +0800 CST
  • Martin Hope
    markdorison 你如何mysqldump特定的表? 2011-12-17 12:39:37 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 对 SQL 查询进行计时? 2011-06-04 02:22:54 +0800 CST
  • Martin Hope
    Jonas 如何从 PostgreSQL 中的选择查询中将值插入表中? 2011-05-28 00:33:05 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 列出所有数据库和表? 2011-02-18 00:45:49 +0800 CST

热门标签

sql-server mysql postgresql sql-server-2014 sql-server-2016 oracle sql-server-2008 database-design query-performance sql-server-2017

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve