select * from (
select T.col.value('@Kind','varchar(30)') as Attribute_King,
T.col.value('.','varchar(30)') as StrVal
from @xml_doc.nodes('//*:Attribute') as T(col)
) as p
PIVOT (
MAX(Attribute_King) for [StrVal] in([230425416398244922], [Payment])
) as piv
select *
, case when exists (select 1 from records r where r.idObject = o.id and r.Month = 'Май') then 1 else null end as record_exists
from Objects o
with months as (
select 'Январь' as m
union all select 'Февраль' as m
...
union all select 'Декабрь' as m
)
select o.*, mo.m
, case when exists (select 1 from records r where r.idObject = o.id and r.Month = mo.m) then 1 else null end as record_exists
from Objects o, months mo
Verify that the instance name is correct and that SQL Server is configured to allow remote connections.
declare @n table (id int);
insert into @n values (1), (2), (3), (5), (6), (7), (8), (15), (16), (20), (21), (22), (23), (30), (31), (55)
select diff, min(id) as range_from, max(id) as range_to
from (
select
id
, id - row_number() over (order by id) as diff
from @n
) x
group by diff
having min(id) <> max(id) -- опционально, если нужны именно диапазоны
order by diff
Taking all the columns via * is available only if tables are joined, not subqueries.
join (select DocumentRef, DocumentNodeStaticGUIDRef, DocumentNodeValue from DocumentNode) dn2 on dn2.DocumentRef = (select T.[value].value ('.', 'int') from DocumentSettingXML.nodes('/DocumentSetting/PreviousDocumentRef') as T([value]))
and dn1.DocumentNodeStaticGUIDRef = dn2.DocumentNodeStaticGUIDRef
where
(select T.[value].value ('.', 'int') from DocumentSettingXML.nodes('/DocumentSetting/PreviousDocumentRef') as T([value])) is not null
WITH [tree] ([sp_id], [sp_parent], [lvl])
AS
(
SELECT [sp_id],
[sp_parent],
1 as [lvl]
FROM [site_pages_new]
WHERE [sp_id] = 2
UNION ALL
SELECT [inner].[sp_id],
[inner].[sp_parent],
[tree].[lvl] + 1
FROM [site_pages] AS [inner]
JOIN [tree]
ON [inner].[sp_parent] = [tree].[sp_id]
WHERE [tree[.[lvl] < @level
)
Файл позволяет вернуться к любой точке времени и восстановить базу на указанное время.
Подскажите как через планировщик настроить сжатие и очистку этого файла после успешно сделанного бэкапа?
SELECT `cms`.`vote_values`.`user_id`,`cms`.`vote_values`.`username`,`ip`, count(*) as cnt,
count(CASE WHEN `user_vote`=5 THEN 1 ELSE NULL END) as cnt5,
count(CASE WHEN `user_vote`=4 THEN 1 ELSE NULL END) as cnt4,
count(CASE WHEN `user_vote`=3 THEN 1 ELSE NULL END) as cnt3,
count(CASE WHEN `user_vote`=2 THEN 1 ELSE NULL END) as cnt2,
count(CASE WHEN `user_vote`=1 THEN 1 ELSE NULL END) as cnt1,
`user_posts`,DATE_FORMAT(FROM_UNIXTIME(`user_regdate`), '%e %b %Y') AS 'date_formatted',`user_avatar`,`user_email`
FROM `cms`.`vote_values` left join `test`.`phpbb_users`
on `cms`.`vote_values`.`user_id`= `test`.`phpbb_users`.`user_id`
where `vote_id`=5 GROUP BY `cms`.`vote_values`.`user_id` ORDER BY `vote_values`.`ip` ASC