I have the a stored procedure to generate an XML document based on the UBL-TR-2.1 standard. This is the query where the xml data is generated: A sample output of this query is this XML file: This works so far so good. But now some XML elements shall have attribute in the element itself. One example is: How ca…
Tag: sql-server
Why does SQL Server read uncommitted data when the default isolation level is READ COMMITTED?
You have a dbo.inventory table and the itemsInStock is 10. Let’s say you run this query: (and you don’t commit the transaction) Why is SQL Server reading a 5 if it hasn’t been committed yet and the default isolation is read committed? Answer Obviously a transaction needs to see everything it…
Find start date and end date from the employee time clock
I am trying to find out star date and end date for the employee time clock. Following is the example of the data I have. Output wanted: I have to find the start date and end date of the person based on eventtime and activitycode. The start date will be event time column and I have to calculate end date
SQL change a table into another format
I have a table like this: Faculty Program Number_of_enrolled Science Financial Modelling 25 Science Actuarial Science 30 Science Statistics 28 Science Biology …
Stuck on final SQL query
I’m busy creating a report and am stuck with how to structure the final query. I have a sub-query that returns the following result set I need the final query result to look like this: I know I can …
SQL: Retrieve Distinct for different columns
I have the following scenario: In a SQL-Table I have the following columns: |—————————————-|————————————-| | Col 1 |…
SQL Server: table join based on record-dependent values
There’s a general type of query I’m trying to perform, and I’m not sure how to express it in words so that I can find a discussion of best practices and examples for executing it. Here’s an example …
SQL Server query to find where all preceding numbers are not included per each ID for a specific column
I am having a hard time trying to explain this succinctly but basically I need to query Table A for each ID number and find where in the positions column there are missing sequential numbers for each …
Query to generate map table to matrix table
I have 1 map table Group Task —– —– Admin Add Admin Edit Admin Delete Admin View User View I need to generate it in a matrix table like Task Admin User —— —— —— Add …
How to pull the latest records added in a table?
I want to pull the records associated with the latest VERSION_ID. FILE_EXTRACT_VERSION table looks like this: FILE_EXTRACT_VERSION_SPECS table looks like this: I want to write a query to pull records with the latest VERSION_ID (latest can be segregated by the latest date they have been added) Here is what I h…