Viewing 15 posts - 226 through 240 (of 297 total)
or maybe
declare @first DATE = '20200101';
insert into dbo.report (First_Of_Month, Customers_Count)
select top(20)
dateadd(d,1-day(saledate),saledate) as First_Of_Month,
count(distinct customerid) as Customers_Count
from Sales
where...
August 11, 2021 at 6:18 pm
Correct, if the length is not explicitly declared, a VARCHAR type variable is defined as being one byte long. 🙂
varchar [ ( n | max ) ] Variable-size string data.
When n isn't specified in a data...
August 11, 2021 at 5:28 pm
I'm not at all sure I have understood your question correctly, but this query does produce the desired outcome:
WITH
MultiCodes AS (
SELECT PartID, CodeTypeId, zValue
FROM #tradecode
GROUP BY...
August 7, 2021 at 10:06 pm
If you simply want to get rid of the decimal point, you can use the REPLACE funtion to replace it with a zero-length string, i.e.
SELECT REPLACE(yourColumn, '.' ,'') AS yourColumn
I'm...
August 6, 2021 at 1:25 pm
Building on what Ant-Green wrote, you can use this:
select *
from sys.dm_exec_sessions s
inner join msdb.dbo.sysjobs j
on convert(char(34),convert(binary(16),j.job_id),1) = substring(s.program_name, charindex('(Job 0x',s.program_name,1)+5,34)
where s.program_name like 'SQLAgent%Jobstep%'
and j.name='TEST' --...
August 6, 2021 at 11:34 am
You query produced the correct results. You need to use your reporting tool to handle the display that you want. SQL will not produce what you are looking for as...
August 6, 2021 at 8:02 am
Test data:
create table #CaseNames (
"Case ID" varchar(10) not null,
"Case Name" varchar(50) null,
constraint CaseName_PK primary key (
"Case ID")
)
create table #CaseFlows (
"Case Flow ID" varchar(10) not null,
"Case ID" varchar(10)...
August 5, 2021 at 8:33 am
This is probably just contributing to the guessing game, but I'll ask anyway...
Based on the difference in the number of records (your statement that the file has 2881 rows and...
May 19, 2021 at 8:09 am
One of my top use cases for APPLY is with a TOP(1), which is hard to achieve any other way, like for example selecting the latest price, i.e. something like...
May 5, 2021 at 11:42 am
You really should take a timeout, step back and seriously consider changing the structure of that table.
If you change the app_time and end_time into columns of type time(0), this would...
March 5, 2021 at 12:14 pm
There are a few additional variations that will achieve the same. The resulting query plan will probably look slightly different too.
update pwc
set pwc.companyId = p.CompanyId
...
March 5, 2021 at 9:51 am
The EOMONTH() function returns the last day of the month of a specified date, with an optional offset. The EOMONTH() function accepts two arguments: start_date is a date expression that evaluates to a date. The EOMONTH() function returns the last day of...
March 4, 2021 at 3:26 pm
The standard behavior for concatenation of strings is that if one of the strings to be concatenated is a null the concatenated string will also be null.
You can change this...
February 25, 2021 at 11:14 pm
select
PartId,
FeatureName,
Status,
case when exists (
select * from #parts
where PartId=p.PartId
and FeatureName=p.FeatureName
group by PartId, FeatureName
having count(distinct status) > 1
)
then 'Have Multistatus' else Comment end as...
February 25, 2021 at 10:54 pm
The picture you posted is not a table by definition. It's got duplicate rows! You have no key or constraints. The strings you posted are not how we represent...
February 25, 2021 at 8:55 pm
Viewing 15 posts - 226 through 240 (of 297 total)