Viewing 15 posts - 16 through 30 (of 670 total)
I tried to just add a column to the table with a default value of the current day but it errors out with because there is no date (Column 14)...
For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
January 7, 2022 at 8:08 pm
declare @t table (tablename varchar(100))
insert into @t values
('dbo.mytable'),
('etl.dbo.table'),
('koagvakjnonsenseajg4648.dbo.RandomTableForSSChahfhaijfhfhf5664646'),
('nonsensetable')
select tablename,
Substring(tablename, charIndex('dbo.',tablename), len(tablename))
from @t
where charIndex('dbo.',tablename) > 0
For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
January 5, 2022 at 5:00 pm
removed
For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
January 5, 2022 at 4:53 pm
if you provide more relevant data, we can maybe help
For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
December 29, 2021 at 7:58 pm
Try joining to it
Create table #table1 (PrintOrderNo int,
PayGroupID int,
LineNumber int,
CompensationDescription varchar(10))
insert into #table1 values
(1,1,1,'test1'),
(1,1,2,'test2'),
(2,1,1,'test3'),
(2,1,2,'test4'),
(3,1,1,'test1')
select
PrintOrderNo as "@PrintOrderID"
,PayGroupID as "@PayGroup"
,(
select
LineNumber as "@DetailNo"
,CompensationDescription as "@Description"
FROM #Table1...
For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
December 29, 2021 at 5:02 pm
Remove the comp alias. Also, that nested select is returning all rows from Table1 for LineNumber and CompensationDescription regardless of which print order no it belongs to
Create...
For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
December 29, 2021 at 3:20 pm
This is the best line, I'll make sure I skip over any of your questions. Glad you got it 'resolved'
Doing it with create scripts and DDL and all the bullshit...
For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
December 29, 2021 at 3:12 pm
Not sure what you are asking. Max of what??
For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
December 2, 2021 at 7:36 pm
is c.name really = to 'x'?? what does this return?
SELECT CASE
WHEN
(
CS.replica_server_name IS NULL
OR CS.replica_server_name = ''
) THEN
N'NOTPRIMARY'
ELSE
CS.replica_server_name
END,
c.name
FROM sys.availability_groups_cluster C
INNER JOIN sys.dm_hadr_availability_replica_cluster_states CS
ON CS.group_id = C.group_id
INNER JOIN sys.dm_hadr_availability_replica_states RS
ON RS.replica_id =...
For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
November 24, 2021 at 2:34 pm
I think you want to check the entre table for fields that are null or have an empty string. You can try something like this
DECLARE @tb nvarchar(512) = N'dbo.[salescube_export]';
DECLARE @sql...
For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
November 18, 2021 at 8:49 pm
declare @NumRecords int = 1555201,
@NumInBatch int = 800,
@NumGroups int = 0,
@count int = 0
while (case when @Count = 0 then @NumInBatch else @NumRecords/(@count) end) >= @NumInBatch
begin
print('ID =...
For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
October 27, 2021 at 3:24 pm
I believe that the fast forward cursor of SQL Server is a great tool to use if, and only if, multiple actions need to be taken on each record...
For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
October 19, 2021 at 8:02 pm
Have you thought about how many rows are in the table to begin with? If 35m and you're deleting 30m, maybe a faster approach, to
begin with, is to insert 5m...
For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
October 15, 2021 at 11:53 am
I echo what the others are saying. Can you provide some sample data as well as how you are determining the @DaysToAdd parameter for each date?
For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
October 8, 2021 at 3:57 pm
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 better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
August 5, 2021 at 5:05 pm
Viewing 15 posts - 16 through 30 (of 670 total)