i have large sql query converts numeric date data type date time value , further specifies search based on requirements. when run query i'm seeing column names there no data in columns, titles of columns in order: dataset, date, time, msgid, parms, dataset when order should be: data, time, dataset, media (separate column substring of parms). showing data past 2 days instead of entire database, problem.
i need in displaying columns in order data present of columns. if can make suggestions or modificiations existing sql query required output, appreciated. know quick fix expert programmer, i'm still learning ropes , require assistance.
this sql query:
select [object] [dataset], cast(dateadd(hour,-4,convert(datetime,left([date],8)+' '+ substring([date],10,2)+':'+ substring([date],12,2)+':'+ substring([date],14,2)+'.'+ substring([date],15,3))) date) 'date', left(cast(dateadd(hour,-4,convert(datetime,left([date],8)+' '+ substring([date],10,2)+':'+ substring([date],12,2)+':'+ substring([date],14,2)+'.'+ substring([date],15,3))) time),8) 'time', msgid, parms, case when msgid = '61' substring(parms,35,6) else '' --optional else end [dataset] ( select itemid, convert(varchar(18),[date]) [date], [object], msgid, parms jnldatasection cast(substring(convert(varchar(50), [date]), 0, 5) + '-' + substring(convert(varchar(50), [date]), 5, 2) + '-' + substring(convert(varchar(50), [date]), 7, 2) datetime) = convert(date, dateadd(day, -1, getdate()))) --converting date again remove time part substring(parms,35,6) = 'x05219' [media] order [date] desc;
please note: i'm using sql server management studio 2008.
now, looks extraction [date] date , time incorrect. putting same string 'date' , 'time'
Comments
Post a Comment