Click here to Skip to main content
14,930,193 members
Home / Discussions / Database
   

Database

 
GeneralRe: SQL Server round trip issue between server and client pc Pin
Gerry Schmitz2-May-21 18:53
mveGerry Schmitz2-May-21 18:53 
QuestionSqlServer (and ADO.NET) mystery... Pin
Super Lloyd27-Apr-21 19:19
MemberSuper Lloyd27-Apr-21 19:19 
AnswerRe: SqlServer (and ADO.NET) mystery... Pin
Richard Deeming27-Apr-21 22:11
mveRichard Deeming27-Apr-21 22:11 
GeneralRe: SqlServer (and ADO.NET) mystery... Pin
Super Lloyd27-Apr-21 22:42
MemberSuper Lloyd27-Apr-21 22:42 
AnswerRe: SqlServer (and ADO.NET) mystery... Pin
Mycroft Holmes28-Apr-21 11:46
professionalMycroft Holmes28-Apr-21 11:46 
QuestionInterval schedule Pin
Member 1462398929-Apr-21 2:56
MemberMember 1462398929-Apr-21 2:56 
AnswerRe: Interval schedule Pin
Victor Nijegorodov27-Apr-21 20:45
MemberVictor Nijegorodov27-Apr-21 20:45 
AnswerRe: Interval schedule Pin
Richard Deeming27-Apr-21 22:08
mveRichard Deeming27-Apr-21 22:08 
You'll need a tally table and a way to concatenate multiple string values. If you're using SQL Server 2017 or later, you can use STRING_AGG[^]; otherwise, use an alternative method[^].

For example:
SQL
SELECT
    StartTime,
    Hours,
    STUFF(T.ScheduleTime, 1, 1, '') As ScheduleTime
FROM
    YourSourceTable As S
    CROSS APPLY
    (
        SELECT
            ',' + CAST(T.ScheduleTime As char(5))
        FROM
            /* Tally table: */
            (
                SELECT TOP ((1 + DateDiff(hour, S.StartTime, '23:00')) / S.Hours) 
                    ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) As N 
                FROM 
                    sys.all_columns
            ) As N
            /* Generated schedule: */
            CROSS APPLY 
            (
                SELECT DateAdd(hour, N.N * S.Hours, S.StartTime) As ScheduleTime
            ) As T
        FOR XML PATH('')
    ) As T (ScheduleTime)
;
Demo[^]



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralRe: Interval schedule Pin
Member 1462398929-Apr-21 2:38
MemberMember 1462398929-Apr-21 2:38 
QuestionRetail inventory management DB Design Pin
vineet123456712-Apr-21 23:42
Membervineet123456712-Apr-21 23:42 
AnswerRe: Retail inventory management DB Design Pin
Victor Nijegorodov13-Apr-21 0:54
MemberVictor Nijegorodov13-Apr-21 0:54 
AnswerRe: Retail inventory management DB Design Pin
RedDk13-Apr-21 12:10
MemberRedDk13-Apr-21 12:10 
QuestionRe: Retail inventory management DB Design Pin
Eddy Vluggen13-Apr-21 13:00
professionalEddy Vluggen13-Apr-21 13:00 
AnswerRe: Retail inventory management DB Design Pin
Mycroft Holmes14-Apr-21 13:32
professionalMycroft Holmes14-Apr-21 13:32 
QuestionConvert date, did I go too far Pin
jkirkerx8-Apr-21 12:50
professionaljkirkerx8-Apr-21 12:50 
AnswerRe: Convert date, did I go too far Pin
Victor Nijegorodov8-Apr-21 20:22
MemberVictor Nijegorodov8-Apr-21 20:22 
AnswerRe: Convert date, did I go too far Pin
Richard Deeming8-Apr-21 22:03
mveRichard Deeming8-Apr-21 22:03 
GeneralRe: Convert date, did I go too far Pin
jkirkerx9-Apr-21 6:14
professionaljkirkerx9-Apr-21 6:14 
GeneralRe: Convert date, did I go too far Pin
Mycroft Holmes9-Apr-21 12:21
professionalMycroft Holmes9-Apr-21 12:21 
GeneralRe: Convert date, did I go too far Pin
jkirkerx9-Apr-21 14:20
professionaljkirkerx9-Apr-21 14:20 
GeneralRe: Convert date, did I go too far Pin
Richard Deeming11-Apr-21 21:10
mveRichard Deeming11-Apr-21 21:10 
AnswerRe: Convert date, did I go too far, Sort of solved Pin
jkirkerx10-Apr-21 14:06
professionaljkirkerx10-Apr-21 14:06 
QuestionExcel Spreadsheet To Database Migration Assistance Pin
Glen McHale6-Apr-21 23:55
MemberGlen McHale6-Apr-21 23:55 
SuggestionRe: Excel Spreadsheet To Database Migration Assistance Pin
CHill607-Apr-21 0:57
mveCHill607-Apr-21 0:57 
AnswerRe: Excel Spreadsheet To Database Migration Assistance Pin
Mycroft Holmes7-Apr-21 12:54
professionalMycroft Holmes7-Apr-21 12:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.