February 10, 2015 at 3:25 am
Hi All!
I made this query, and if you look carefully, you will see, that I forgot an ',' after the second last item I did select.
The resultset did put <NULL> in the last two fields.
When i added a , after 'To_Work', I got the result i wanted, a NULL for to_work, and a value for originating_Shift_Type
But to give me some understanding, i am at a loss of why my SQL2012 accepted the query without the ',', and what the meaning of the answer is, when you forget it.
If you look under the select statement, I have documented the table.
select
dato,
std,
specialvagt,
daekbemand,
extratimer,
overarbtimer,
manuel,
beskyttet,
confirmed,
vacationtype,
breakswish,
dutyrosterid,
employeeid,
employeegroupid,
childforcaredayid,
originatingstaffingrequirementid,
shifttype,
fromtime,
totime,
loginid,
statusno,
Time_Stamp,
comment,
ID,
Is_Free_sat,
Is_Center_Opening,
is_fo_day,
SavedDuty_Id,
mTid_Id,
duty_released,
FROM_FLEXJOB,
Work_minutes_travel_days,
From_Work,
To_Work
originating_Shift_Type
from dbo.dutyrostershift
WHERE (ShiftType <> 1 OR SpecialVagt = 1) AND dutyrosterid = 3 and dato BETWEEN '20141025' and '20141025'
Table :
CREATE TABLE [dbo].[dutyrostershift](
[dato] [datetime] NULL,
[std] [tinyint] NULL,
[specialvagt] [tinyint] NULL,
[daekbemand] [tinyint] NULL,
[extratimer] [int] NULL,
[overarbtimer] [int] NULL,
[manuel] [tinyint] NULL,
[beskyttet] [tinyint] NULL,
[confirmed] [tinyint] NULL,
[vacationtype] [varchar](50) NULL,
[breakswish] [tinyint] NULL,
[dutyrosterid] [int] NULL,
[employeeid] [int] NULL,
[employeegroupid] [int] NULL,
[childforcaredayid] [int] NULL,
[originatingstaffingrequirementid] [int] NULL,
[shifttype] [int] NULL,
[fromtime] [int] NULL,
[totime] [int] NULL,
[id] [int] IDENTITY(1,1) NOT NULL,
[LoginID] [int] NULL,
[StatusNo] [int] NULL,
[Time_Stamp] [datetime] NULL,
[Comment] [char](120) NULL,
[Is_Free_sat] [tinyint] NULL,
[Is_Center_Opening] [tinyint] NULL,
[is_fo_day] [tinyint] NULL,
[SavedDuty_Id] [int] NULL,
[mTid_Id] [int] NULL,
[duty_released] [tinyint] NULL,
[recordstatus] [tinyint] NULL,
[FROM_FLEXJOB] [tinyint] NULL,
[Work_minutes_travel_days] [int] NULL,
[from_work] [int] NULL,
[to_work] [int] NULL,
[originating_Shift_Type] [int] NULL,
CONSTRAINT [pk_dbo_pk_dutyrostershift] PRIMARY KEY CLUSTERED
(
[id] ASC
)
Best regards
Edvard Korsbæk
February 10, 2015 at 3:46 am
SQL Server will have interpreted originating_Shift_Type as an alias for the To_work column.
It's the same as:
select To_work [originating_Shift_Type]
from dbo.dutyrostershift
where ...
February 10, 2015 at 3:50 am
Thanks!
0,1 0/00 less newbie now!
Edvard Korsbæk
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply