INSERT INTO Activity_Feed (userID,Type,DataIDs,PodID)
VALUES ( 1437
, 'eventattend'
, (SELECT LEFT(EventID, LEN(eventID) - 1 as nvarchar)
FROM (
SELECT EventiD + ', '
FROM events
FOR XML PATH ('')) c (EventID))
, 5)
Basically I want to take a bunch of IDs from a table and insert them as a comma delimited string into a varchar field.
E.g.
Activity_Feed (table)
activityID 1
userID 2
DataIDs 1,3,4,56,367 // This would be the (Select Ids FROM bit)
I want to take a bunch of RSVP IDs from a table and stick their IDs in the field...
To further explain I wanted to avoid normalizing the query because of the nature of this query. Let me know if I should still separate out the data...
The activity feed works like this...
I create a new entry in activity with a type of event_attending
(which is an event I am attending.
I timestamp it, I enter the ID for the event in the dataIDs
field any new activity matching event_attending
in a 6 hour period fires an update
record rather than insert
I keep the timestamp the same but update the ID's that are associated with that time period so basically update the IDs with the latest event attendance within that time period.
I thought normalizing seemed like overkill :D is there such thing as overkill with normalization?