SQL Server adding its own aliases and getting them wrong -


i wrote following short, simple view:

--drop view reportobjects.vstarts; create view reportobjects.vstarts select * reportobjects.vlothistory         lottype = 'some constant value'     , cdoname = 'some constant value'     , specid = 'some constant value' 

when execute script click "design" on view in ssms, this:

select containername, specname, productname, lotstatus, cdoname, resourcename lottype, employeename workflowname, lottype dieqty,                    workflowname lotqty, dieqty txndate, lotqty txndategmt, txndate containerid, txndategmt historymainlineid, containerid productid,                    historymainlineid specid, productid workflowid, specid workflowbaseid, workflowid workflowstepid, workflowbaseid, workflowstepid, resourceid,                    employeeid     reportobjects.vlothistory  (lottype = 'some constant value') , (cdoname = 'some constant value') , (specid = 'some constant value') 

see problem? dieqty txndate, lotqty txndategmt, txndate containerid it's aliasing columna name of columnc!

i've tried dropping/recreating view several times. know can argued select * icky, that's beside point (and is necessary in production code).

the view above selecting view defined as:

create view reportobjects.vlothistory select     lot.containername,     hist.specname,     hist.productname,     lot.status lotstatus,     hist.cdoname,     hist.resourcename,     hist.employeename,     lot.csilottype lottype,     workflowbase.workflowname,     hist.qty dieqty,     hist.qty2 lotqty,     hist.txndate,     hist.txndategmt,     lot.containerid,     hist.historymainlineid,     hist.productid,     hist.specid,     workflow.workflowid,     workflow.workflowbaseid,     hist.workflowstepid,     hist.resourceid,     hist.employeeid ods.mes_schema.container lot     left join ods.mes_schema.historymainline hist         on lot.containerid = hist.containerid     left join ods.mes_schema.workflowstep ws         on hist.workflowstepid = ws.workflowstepid     left join ods.mes_schema.workflow         on ws.workflowid = workflow.workflowid     left join ods.mes_schema.workflowbase         on workflowbase.workflowbaseid = workflow.workflowbaseid 

does know why ssms or sql server eating query , spitting out nonsense? note not using ssms tools create view -- using create view shown above.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -