Skip to content

Tag: tsql

Remove overlapping date intervals

I have two tables in my sql server database : PlannedPeriods : containing periods of future events UnavailabledPeriods : list or periods that are not available Here’s an example for structure and data : I would like to remove all unavailable periods from the planned periods in order to obtain this resul…

SQL STUFF FOR XML with specific grouping

I’m working in SQL Server 2014, and I have the following simple data, which tracks calling history of users: I need to group the ACTIVITY values into one field, which effortlessly be done using the STUFF FOR XML function: However I need to conditionally group these, on the condition that there was more …

Is my understanding of how FIELDQUOTE works correct?

I am using Azure Synapse and I m querying the following CSV file: Here is the T-SQL query: Here is the output: I then altered the CSV file to add a colon just before the letter G as so: I get: This lead me to make the following conclusions about FIELDQUOTE: The query as a whole scans each row, character

Creating a Data Dictionary with example data (SQL)

I am looking to run a script on a SQL database to create a Data Dictionary with an example of the data for each field. To keep it simple I would just like to include the data from the first row of each table along with each table name and column name So something like this: Table Name Field Name

Sybase select value from XML field

I have a table named data_values stored in SYBASE in the following format: The value field has the following XML format: I want to select from the value field values like value1, value2, etc. but I can’t find a correct query to do this. I have tried: also value is a reserved keyword I think and I need t…