Skip to content

Tag: sql-server

Is it possible to use a SELECT statement inside a CONCAT?

I’m trying to create a string from table values, along with some text to make it more readable. The only problem I’m having is that I can’t get the SELECT statement to work inside my CONCAT. It’s been bugging me for quite some time now, and I would appreciate any feedback on what I&#82…

Xquery Get Consecutive Distinct Values

Trying to get consecutive distinct from the following XML. Expected Result : Current Result : Code : The distinct-values get distinct from the whole set, but I would like to get distinct values only if there are consecutive. Answer We have a pure XQuery solution. SQL Output

String or binary data of ” would be truncated

I’m trying to resize a column down to 64 characters in length: but I get the following error: String or binary data would be truncated in table ‘dbo.consumption’, column ‘resourceGroup’. Truncated value: ”. This doesn’t make sense to me: how can you truncate nothing? …

Concatenate 2 rows into one in SQL

I have a very simple data structure with just 3 tables: requests employees teams Basically, what I need is to concatenate 2 different SQL selects into one (so that the query could return just one row). If there’s an employee associated with a request, then return their name (title) and concatenate it wi…

SQL query based on column condition

I have a sql table in which below are the columns. I’m using sql server. Id, name, device and information on if device is active or not. Need to have a SQL query for below scenario: I want to display firstdevice, seconddevice columns below based on isActive column. If isACTIVE is 1 then, fill the device…

Trying to extract data form SQL using PS script

I have been trying to get a PS script to work in extracting files (pdf, word, etc.) from an SQL Server database. I came across the PowerShell script below. The script runs and populates the destination folder but all files are 0 bytes and during the script execution. It throws the error: “Exporting Obje…