SQL Server(MsSQL)Concat错误

时间:2016-01-08 16:06:10

标签: sql sql-server

我有以下代码在Sybase数据库中执行完全正常,但同样的查询在MsSQL服务器中给出了错误。

EXCEPTION: Cannot resolve all parameters for RouteData(?). Make sure they all have valid type or annotations.BrowserDomAdapter.logError @ browser_adapter.js:76BrowserDomAdapter.logGroup @ browser_adapter.js:86ExceptionHandler.call @ exception_handler.js:56(anonymous function) @ application_ref.js:183NgZone._notifyOnError @ ng_zone.js:430collection_1.StringMapWrapper.merge.onError @ ng_zone.js:325run @ core.js:99(anonymous function) @ ng_zone.js:343zoneBoundFn @ core.js:69lib$es6$promise$$internal$$tryCatch @ es6-promise.js:326lib$es6$promise$$internal$$invokeCallback @ es6-promise.js:338lib$es6$promise$$internal$$publish @ es6-promise.js:309(anonymous function) @ microtask.js:37microtask @ ng_zone.js:383run @ core.js:96(anonymous function) @ ng_zone.js:343zoneBoundFn @ core.js:69lib$es6$promise$asap$$flush @ es6-promise.js:120
browser_adapter.js:76STACKTRACE:BrowserDomAdapter.logError @ browser_adapter.js:76ExceptionHandler.call @ exception_handler.js:58(anonymous function) @ application_ref.js:183NgZone._notifyOnError @ ng_zone.js:430collection_1.StringMapWrapper.merge.onError @ ng_zone.js:325run @ core.js:99(anonymous function) @ ng_zone.js:343zoneBoundFn @ core.js:69lib$es6$promise$$internal$$tryCatch @ es6-promise.js:326lib$es6$promise$$internal$$invokeCallback @ es6-promise.js:338lib$es6$promise$$internal$$publish @ es6-promise.js:309(anonymous function) @ microtask.js:37microtask @ ng_zone.js:383run @ core.js:96(anonymous function) @ ng_zone.js:343zoneBoundFn @ core.js:69lib$es6$promise$asap$$flush @ es6-promise.js:120
browser_adapter.js:76Error: Cannot resolve all parameters for RouteData(?). Make sure they all have valid type or annotations.
    at NoAnnotationError.BaseException [as constructor] (http://0.0.0.0:3000/vendor.bundle.js:4393:24)
    at new NoAnnotationError (http://0.0.0.0:3000/vendor.bundle.js:5267:17)
    at _dependenciesFor (http://0.0.0.0:3000/vendor.bundle.js:4317:16)
    at resolveFactory (http://0.0.0.0:3000/vendor.bundle.js:4199:25)
    at _normalizeProvider (http://0.0.0.0:3000/vendor.bundle.js:4281:20)
    at http://0.0.0.0:3000/vendor.bundle.js:4262:14
    at Array.forEach (native)
    at Array.forEach (http://0.0.0.0:3000/vendor.bundle.js:37520:15)
    at _normalizeProviders (http://0.0.0.0:3000/vendor.bundle.js:4260:16)
    at Object.resolveProviders (http://0.0.0.0:3000/vendor.bundle.js:4230:46)
    at Function.Injector.resolve (http://0.0.0.0:3000/vendor.bundle.js:3012:28)
    at Function.ProtoElementInjector._createProvidersWithVisibility (http://0.0.0.0:3000/vendor.bundle.js:16062:39)
    at Function.ProtoElementInjector.create (http://0.0.0.0:3000/vendor.bundle.js:16048:31)
    at _createElementBinder (http://0.0.0.0:3000/vendor.bundle.js:14821:73)
    at _ProtoViewInitializer._visitBeginBoundElement (http://0.0.0.0:3000/vendor.bundle.js:14751:30)
    at _ProtoViewInitializer.visitBeginComponent (http://0.0.0.0:3000/vendor.bundle.js:14734:22)
    at BeginComponentCmd.visit (http://0.0.0.0:3000/vendor.bundle.js:18383:25)
    at Object.visitAllCommands (http://0.0.0.0:3000/vendor.bundle.js:18431:18)
    at ProtoViewFactory._initializeProtoView (http://0.0.0.0:3000/vendor.bundle.js:14665:30)
    at ProtoViewFactory._createComponent (http://0.0.0.0:3000/vendor.bundle.js:14646:19)
    at createComponent (http://0.0.0.0:3000/vendor.bundle.js:14694:30)
    at _ProtoViewInitializer.visitBeginComponent (http://0.0.0.0:3000/vendor.bundle.js:14733:32)
    at BeginComponentCmd.visit (http://0.0.0.0:3000/vendor.bundle.js:18383:25)
    at Object.visitAllCommands (http://0.0.0.0:3000/vendor.bundle.js:18431:18)
    at ProtoViewFactory._initializeProtoView (http://0.0.0.0:3000/vendor.bundle.js:14665:30)
    at ProtoViewFactory.initializeProtoViewIfNeeded (http://0.0.0.0:3000/vendor.bundle.js:14660:19)
    at AppViewManager_.createRootHostView (http://0.0.0.0:3000/vendor.bundle.js:16885:33)
    at http://0.0.0.0:3000/vendor.bundle.js:14460:51
    at Zone.run (http://0.0.0.0:3000/vendor.bundle.js:40985:18)
    at Zone.run (http://0.0.0.0:3000/vendor.bundle.js:14051:43)
    at zoneBoundFn (http://0.0.0.0:3000/vendor.bundle.js:40958:20)
    at lib$es6$promise$$internal$$tryCatch (http://0.0.0.0:3000/vendor.bundle.js:40203:17)
    at lib$es6$promise$$internal$$invokeCallback (http://0.0.0.0:3000/vendor.bundle.js:40215:18)
    at lib$es6$promise$$internal$$publish (http://0.0.0.0:3000/vendor.bundle.js:40186:12)
    at http://0.0.0.0:3000/vendor.bundle.js:41435:6
    at microtask (http://0.0.0.0:3000/vendor.bundle.js:14091:30)
    at Zone.run (http://0.0.0.0:3000/vendor.bundle.js:40985:18)
    at Zone.run (http://0.0.0.0:3000/vendor.bundle.js:14051:43)
    at zoneBoundFn (http://0.0.0.0:3000/vendor.bundle.js:40958:20)
    at MutationObserver.lib$es6$promise$asap$$flush (http://0.0.0.0:3000/vendor.bundle.js:39997:10)

-----async gap-----
Error
    at _getStacktraceWithUncaughtError (http://0.0.0.0:3000/vendor.bundle.js:43301:27)
    at Zone.fork (http://0.0.0.0:3000/vendor.bundle.js:43359:41)
    at Zone.bind (http://0.0.0.0:3000/vendor.bundle.js:40956:49)
    at bindArguments (http://0.0.0.0:3000/vendor.bundle.js:41190:30)
    at lib$es6$promise$promise$$Promise.obj.(anonymous function) [as then] (http://0.0.0.0:3000/vendor.bundle.js:41210:38)
    at DynamicComponentLoader_.loadAsRoot (http://0.0.0.0:3000/vendor.bundle.js:14459:52)
    at di_1.provide.useFactory (http://0.0.0.0:3000/vendor.bundle.js:13344:48)
    at Injector._instantiate (http://0.0.0.0:3000/vendor.bundle.js:3344:28)
    at Injector._instantiateProvider (http://0.0.0.0:3000/vendor.bundle.js:3295:26)
    at Injector._new (http://0.0.0.0:3000/vendor.bundle.js:3284:22)
    at InjectorInlineStrategy.getObjByKeyId (http://0.0.0.0:3000/vendor.bundle.js:2799:34)
    at Injector._getByKeyDefault (http://0.0.0.0:3000/vendor.bundle.js:3480:38)
    at Injector._getByKey (http://0.0.0.0:3000/vendor.bundle.js:3426:26)
    at Injector.get (http://0.0.0.0:3000/vendor.bundle.js:3103:22)
    at http://0.0.0.0:3000/vendor.bundle.js:13615:46
    at Zone.run (http://0.0.0.0:3000/vendor.bundle.js:40985:18)
    at Zone.run (http://0.0.0.0:3000/vendor.bundle.js:14051:43)
    at NgZone.run (http://0.0.0.0:3000/vendor.bundle.js:14000:41)
    at ApplicationRef_.bootstrap (http://0.0.0.0:3000/vendor.bundle.js:13606:21)
    at Object.bootstrap (http://0.0.0.0:3000/vendor.bundle.js:18958:91)
    at HTMLDocument.main (http://0.0.0.0:3000/main.bundle.js:12:16)
    at Zone.run (http://0.0.0.0:3000/vendor.bundle.js:40985:18)
    at HTMLDocument.zoneBoundFn (http://0.0.0.0:3000/vendor.bundle.js:40958:20)

-----async gap-----
Error
    at _getStacktraceWithUncaughtError (http://0.0.0.0:3000/vendor.bundle.js:43301:27)
    at Zone.fork (http://0.0.0.0:3000/vendor.bundle.js:43359:41)
    at NgZone._createInnerZone (http://0.0.0.0:3000/vendor.bundle.js:14039:15)
    at new NgZone (http://0.0.0.0:3000/vendor.bundle.js:13825:37)
    at createNgZone (http://0.0.0.0:3000/vendor.bundle.js:13366:13)
    at PlatformRef_.application (http://0.0.0.0:3000/vendor.bundle.js:13467:34)
    at Object.bootstrap (http://0.0.0.0:3000/vendor.bundle.js:18958:65)
    at HTMLDocument.main (http://0.0.0.0:3000/main.bundle.js:12:16)
    at Zone.run (http://0.0.0.0:3000/vendor.bundle.js:40985:18)
    at HTMLDocument.zoneBoundFn (http://0.0.0.0:3000/vendor.bundle.js:40958:20)BrowserDomAdapter.logError @ browser_adapter.js:76ExceptionHandler.call @ exception_handler.js:59(anonymous function) @ application_ref.js:183NgZone._notifyOnError @ ng_zone.js:430collection_1.StringMapWrapper.merge.onError @ ng_zone.js:325run @ core.js:99(anonymous function) @ ng_zone.js:343zoneBoundFn @ core.js:69lib$es6$promise$$internal$$tryCatch @ es6-promise.js:326lib$es6$promise$$internal$$invokeCallback @ es6-promise.js:338lib$es6$promise$$internal$$publish @ es6-promise.js:309(anonymous function) @ microtask.js:37microtask @ ng_zone.js:383run @ core.js:96(anonymous function) @ ng_zone.js:343zoneBoundFn @ core.js:69lib$es6$promise$asap$$flush @ es6-promise.js:120
main.ts:22NoAnnotationError {message: "Cannot resolve all parameters for RouteData(?). Make sure they all have valid type or annotations.", stack: "Error: Cannot resolve all parameters for RouteData…h (http://0.0.0.0:3000/vendor.bundle.js:39997:10)"}

错误是:列名称无效'/'。

1 个答案:

答案 0 :(得分:3)

在MSSQL中(显然是标准 - 请参阅注释),字符串封装在单引号中,例如...... 'here is a string'

你将它们翻倍以逃避它们...... 'here''s another string that includes a single quote'

双引号是指对象。它至少在我的经验中并不常用。我更喜欢方括号,但它们是等价的。例如,这两个完全相同......

SELECT
    "Some Field"
FROM
    YourTable

SELECT
    [Some Field]
FROM
    YourTable

因此,在您的代码中,"/"正在寻找一个名为fowardslash的字段。简单纠正......

select
  column1,
  (
    Case when  ABC < 0 then CONVERT(varchar(50), Convert(int,PQR)) + '/' + CONVERT(varchar(50), Convert(int,ABC)) 
        else CONVERT(varchar(50), Convert(int,PQR)) 
    end
  )  as column2, 
  column3,
  column4
FROM SAMPLE_TABLE