Viewing 15 posts - 61 through 75 (of 1,438 total)
No errors with SQL 2017 (14.0.3015.40)
January 28, 2021 at 1:39 pm
See if this helps
SELECT
root.[key] AS [Order]
, resultval.[key] , resultval.[value]
FROM OPENJSON ( @jsondata ) AS root
CROSS APPLY OPENJSON ( root.value, '$.result') AS resultval
January 21, 2021 at 9:05 am
Maybe this?
select ps.*,tc2.* from #partattributes ps
inner join #tradecodecontrol tc on ps.FeatureKey=tc.FeatureKey
inner join #tradecodecontrol tc2...
December 29, 2020 at 9:30 am
Try this
SELECT
X.Y.value('@ID', 'INT') AS ID,
X.Y.value('./@*[local-name()=sql:variable("@ColumnName")][1]', 'VARCHAR(10)') AS Value
FROM @XML.nodes('/row') AS X(Y)
November 27, 2020 at 5:45 pm
Maybe this, assumes a fixed number of generations
WITH CTE AS (
SELECT p1.ID AS RootID, p1.PersonName AS RootName, p1.ID, p1.PersonName, p1.FemParent, p1.MaleParent,
CAST('' AS VARCHAR(1000)) AS...
October 7, 2020 at 2:51 pm
Recursive cte method, won't be very efficient
with cte as (
select top 1 Date1, cast(1 as bigint) as rn
from #temp
order by Date1
union all
select t.Date1, row_number() over(order by t.Date1)...
August 26, 2020 at 1:38 pm
This should work for you
WITH CTE1 AS (
SELECT [ROW_NUMBER],VALUE,
CASE WHEN LAG(VALUE) OVER(ORDER BY [ROW_NUMBER]) IS NULL THEN 1 ELSE 0 END AS ISSTART
FROM T_REST
),
CTE2...
August 14, 2020 at 10:42 am
To make this dynamic have a look here
https://www.sqlservercentral.com/articles/cross-tabs-and-pivots-part-2-dynamic-cross-tabs
July 24, 2020 at 9:59 am
If I understand correctly, this should work for you
SELECT Tenor,
COUNT(CASE WHEN ABS(ColA) > 0 THEN ColA END) + COUNT(CASE WHEN...
July 24, 2020 at 8:07 am
This is the standard SQL 'IS DISTINCT FROM' operator, not current implemented in T-SQL (yet!)
Interesting article below mentions it is implemented in the query processor
https://www.sql.kiwi/2011/06/undocumented-query-plans-equality-comparisons.html
July 1, 2020 at 1:48 pm
The json isn't valid around "Website": "www.test.com": {
declare @json nvarchar(max) = '
{
"id": "9999",
"position": 1,
"visible": true,
...
June 10, 2020 at 8:49 am
I think this is what you're after
declare @json nvarchar(max) = '
{"data": [{"id": "123456", "first_name": "John", "last_name": "Doe", "email": "jdoe@gmail.com", "phone_number": "333-333-3333", "href": "http://jdoe.com", "custom_fields": {"1": "John Doe...
May 26, 2020 at 9:39 pm
This should work for you
Select b.id, b.title, b.nickname, b.href
from openjson(@json)
with ([data] nvarchar(max) '$.data' as json) a
cross apply openjson(a.[data])
with (id int '$.id',
...
May 19, 2020 at 11:04 am
Try this
SELECT v.n2.value('(@*:ObjectName)[1]','varchar(30)') AS Name,
p.n1.value('(@*:ObjectName)[1]','varchar(30)') AS Scope
FROM #SSISTest st
CROSS APPLY st.PackageXML.nodes('//*:Executable') AS p(n1)
CROSS APPLY p.n1.nodes('*:Variables/*:Variable') as v(n2);
May 14, 2020 at 10:34 am
This is as near as I can get. You'll have to add '<?xml version="1.0" encoding="UTF-8"?>' manually. Also you've defined the date as a varchar, it should be a date or...
April 8, 2020 at 1:52 pm
Viewing 15 posts - 61 through 75 (of 1,438 total)