In that case, you just need to add a WHERE clause between the FROM YourTable As T1 and GROUP BY Surname lines:
(SELECT'/' + Surname + ',' + STUFF(
(SELECT'-' + Forename
FROM YourTable As T2
WHERE T2.Surname = T1.Surname
FOR XML PATH(''), TYPE
, 1, 1, '')
FROM YourTable As T1
-- Filter here:WHERE T1.ID = @TheIDToFindGROUPBY Surname
FOR XML PATH(''), TYPE
, 1, 1, '') As CombinedNames
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
If my one of customer saying they could a generate a report withing 30 second before and now they have to wait for 3min so how I can track that as a Senior Technical Support Analyst that whether it is a database issue or programming issue ?
I'm working on a system where data integrity is important so rather than just updating records we're always going to insert a new one, quite often there will be links in the system to previous versions so it'd be useful if this data was easily available.
Previously this system was being developed by a guy who's now left the company, he's been using GUIDs as Ids and that's something I'm tryin get get away from.
The current structure we have is:
RootId is the base ID and Id is the primary key, there is also an Audit table where adding an entry for the ID can mark it as deleted, this makes the select statements a bit over complicated since you have to find the maximum version for each RootId then join back to get the actual data and then join again to find any audit entries.
I was wondering, what other simpler versioning strategies are there?
id - unique id on this table
operation - insert,delete or update
table_name - name of table operation pertains to
col_name - name of the column operation pertains to
key_col - name of the key column operation pertains to
key_val - value of the key column operation pertains to
col_val_prior - value of col_name column before operation
col_val_new - value of col_name column after operation
username - name of user running operation
transaction_dt - datetime trigger was run
batch - guid that uniquely identifies an operation
I then created three triggers that I add to all tables to be audited(the triggers cover insert, update and delete operations).
This allows me to see all operations on tables I wish to audit.
“That which can be asserted without evidence, can be dismissed without evidence.”
Get the records from your database, using a SELECT clause.
Save that response into a variable of type array (or a generic list).
Which language are you actually using? C#, Java, C++, PHP? It depends on which framework and language you're using. The language would allow you to perform such actions on the objects (or the list of the object) that is being returned.
Usually results from the database are in a form of an array or list.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~