Database Mail Setup
online Rebuild available version
Could anyone please let me know what are the sql version supports online rebuild feature?.
especially standard versions that support online rebuild?
baskarlakshmi
what factors need to consider while setting parallelism settings?
Hi All,
Need some advice on setting the parallelism settings.
What value to be set for MAXDOP and cost threshold for parallelism? This is a OLTP instance.
Right now I see the max degree of parallelism = 1 and cost threshold for parallelism = 5.
Environment details
===============
OS Name Microsoft Windows Server 2012 R2 Datacenter
Version 6.3.9600 Build 9600
Other OS Description Not Available
OS Manufacturer Microsoft Corporation
System Manufacturer VMware, Inc.
System Model VMware Virtual Platform
System Type x64-based PC
System SKU
Processor Intel(R) Xeon(R) CPU E5-2697 v3 @ 2.60GHz, 2594 Mhz, 2 Core(s), 2 Logical Processor(s)
Processor Intel(R) Xeon(R) CPU E5-2697 v3 @ 2.60GHz, 2594 Mhz, 2 Core(s), 2 Logical Processor(s)
Processor Intel(R) Xeon(R) CPU E5-2697 v3 @ 2.60GHz, 2594 Mhz, 2 Core(s), 2 Logical Processor(s)
Processor Intel(R) Xeon(R) CPU E5-2697 v3 @ 2.60GHz, 2594 Mhz, 2 Core(s), 2 Logical Processor(s)
Installed Physical Memory (RAM) 120 GB
Total Physical Memory 120 GB
Available Physical Memory 2.77 GB
Total Virtual Memory 134 GB
Available Virtual Memory 14.2 GB
Page File Space 14.0 GB
Page File C:\pagefile.sys
A hypervisor has been detected. Features required for Hyper-V will not be displayed.
SQL Server version
Microsoft SQL Server 2012 (SP4) (KB4018073) - 11.0.7001.0 (X64)
Aug 15 2017 10:23:29
Copyright (c) Microsoft Corporation
Enterprise Edition (64-bit) on Windows NT 6.3 <X64> (Build 9600: ) (Hypervisor)
-- Hardware information from SQL Server 2012 (Query 17) (Hardware Info)
SELECT
cpu_count/hyperthread_ratio AS [Physical CPU Count],
cpu_count AS [Logical CPU Count],
scheduler_count,
hyperthread_ratio AS [Hyperthread Ratio],
physical_memory_kb/1024 AS [Physical Memory (MB)],
committed_kb/1024 AS [Committed Memory (MB)],
committed_target_kb/1024 AS [Committed Target Memory (MB)],
max_workers_count AS [Max Workers Count],
affinity_type_desc AS [Affinity Type],
sqlserver_start_time AS [SQL Server Start Time],
DATEDIFF(hour, sqlserver_start_time, GETDATE()) AS [SQL Server Up Time (hrs)],
virtual_machine_type_desc AS [Virtual Machine Type]
FROM sys.dm_os_sys_info WITH (NOLOCK) OPTION (RECOMPILE);
Go
-- SQL Server NUMA Node information (Query 13) (SQL Server NUMA Info)
SELECT node_id, node_state_desc, memory_node_id, processor_group, online_scheduler_count,
idle_scheduler_count, active_worker_count, avg_load_balance, resource_monitor_state
FROM sys.dm_os_nodes WITH (NOLOCK)
--WHERE node_state_desc <> N'ONLINE DAC' OPTION (RECOMPILE);
go
Thanks,
Sam
sql performance
Hi Experts,
I have multiple questions in one thread. please excuse me. All related to one particular query.
We are seeing some pagelatch_up and pagelatch_sh waittypes for one of the query.
What are these waittypes mean? Will they go hand in hand ? when do we see both together.
How can we minimize or eliminate these waittypes ?
Also, in sp_whoisactive it is shown on PFS page. my other doubt is that, is it PFS page contention is on tempdb or cmx_ors database?
Is there a way to log that tempdb allocation contention or specific database allocation contention happened in the ERRORLOG . Is there a trace flag to log such information in the ERRORLOG? The reason why I am asking this is, we have a cx asking that we are
seeing high waits for a query. if this info is logged somewhere,
we can prove at that particular time frame, there was some contention happening. At this point, we are capturing sp_whoisactive output into a table every 15 mins.
Below is the screenshots of sp_whoisactive and some DPA information.
Thanks,
Sam
How can I bulk insert into deltastore? HOW TO use SqlBulkCopy on a table with Non-Clostered columnstore index efficiently ?
Hello SQL server community,
We have an application that is loading data events in batches.
The application inserts events into SQL Server table with Bulk insert (System.Data.SqlBulkCopy). (in batches of 1-10000)
We have added a non-clustered columnstore index to the table.
Now each bulk insert results in COMPRESSED row group with the size of the batch and after a while things get a bit inefficient => you get lots of relatively small compressed rowstore groups and using the index becomes MUCH slower.
Essentially we are back to times when there was no deltastore on NCCIs
Of course you can run a costly REORGANIZE on your NCCI to merge those tiny closed rowgroups into big ones.
If you execute an insert statement, index records it in the deltastore. And things are handled much more efficiently.
Therefore my question: Is there any way to ask SQL server to treat Bulk insert as normal insert when updating columnstore indexes ?
Another formulation: Is there any way to disable BULKLOAD rowgroup trim reason for columnstore index when bulk-loading data?
Thank you very much,
Alexander
This scripts explains the question more precise:
To run it you need to create a file on filesystem for BULK INSERT
It will create a DB and will clean it up afterwards
Please use SQL Server 2017 (14.0.3223.3) was used
USE [master]
GO
THROW 51000, 'Create a file C:\TestColumnStoreInservVSBulkInsert.txt with content: "test, 1" and comment this line', 1;
CREATE DATABASE TestColumnStoreInservVSBulkInsert
GO
use [TestColumnStoreInservVSBulkInsert]
CREATE TABLE [Table](
[value] [varchar](20) NOT NULL INDEX IX_1 CLUSTERED,
[state] int not NULL
)
CREATE NONCLUSTERED COLUMNSTORE INDEX [NCI_1] ON [dbo].[Table]
(
[value],
[state]
)WITH (DROP_EXISTING = OFF, COMPRESSION_DELAY = 0)
insert into [Table] values (('TestInitail'), (1))
DECLARE @IndexStateQuery VARCHAR(MAX)
SET @IndexStateQuery = 'SELECT i.object_id,
object_name(i.object_id) AS TableName,
i.name AS IndexName,
i.index_id,
i.type_desc,
CSRowGroups.*
FROM sys.indexes AS i
JOIN sys.dm_db_column_store_row_group_physical_stats AS CSRowGroups
ON i.object_id = CSRowGroups.object_id AND i.index_id = CSRowGroups.index_id
ORDER BY object_name(i.object_id), i.name, row_group_id; '
EXEC (@IndexStateQuery)
-- Creates a COMPRESSED rowGroup with 1! record
--QUESTION: How to make this statement add data to Open Rowgroup ?
BULK INSERT [Table] FROM 'C:\TestColumnStoreInservVSBulkInsert.txt' WITH ( FORMAT='CSV', ROWS_PER_BATCH = 1);
EXEC (@IndexStateQuery)
-- Adds one record to existing open rowgroup
insert into [Table] select top 1 * from [Table]
EXEC (@IndexStateQuery)
--Costly fix. Merge and recomrpess closed rowgroups
--ALTER INDEX NCI_1 ON [Table] REORGANIZE
--EXEC (@IndexStateQuery)
--Cleanup
use [master]
alter database [TestColumnStoreInservVSBulkInsert] set single_user with rollback immediate
drop database [TestColumnStoreInservVSBulkInsert]
help switching from non partition table to partitioned table
I've got a partition function which looks like this:
CREATE
PARTITIONFUNCTION [fnSmartSearchResults](smalldatetime)ASRANGERIGHTFORVALUES(
N'2009-02-01T00:00:00'
, N'2009-03-01T00:00:00'
, N'2009-03-02T00:00:00'
, N'2009-03-03T00:00:00'
, N'2009-03-04T00:00:00'
, N'2009-03-05T00:00:00')
Then I got a partition scheme which looks like this:
CREATE
PARTITIONSCHEME [SmartSearchPSchemeResults] ASPARTITION [fnSmartSearchResults] TO([PRIMARY]
, [SS_Results_20090301]
, [SS_Results_20090302]
, [SS_Results_20090303]
, [SS_Results_20090304]
, [SS_Results_20090305]
,[PRIMARY]
)I got a table created on this partition scheme as follow:
CREATE
TABLE [dbo].[ssv5_results_load]([smart_search_result_id] [bigint] NOTNULL,
[smart_search_id] [bigint] NOTNULL,
[provider_id] [tinyint] NOTNULL,
[smart_result_type_id] [bit] NOTNULL,
[smart_result_dmc_id] [smallint] NOTNULL,
[smart_result_dmc_code] [varchar](10)NOTNULL,
[smart_result_hotel_id] [int] NOTNULL,
[SearchDate] [smalldatetime] NOTNULL,
[smart_result_included] [varchar](1000)NULL,
[smart_result_excluded] [varchar](1000)NULL,
[smart_result_promotion] [nvarchar](1000)NULL,
[smart_result_completed] [tinyint] NULL,
smart_result_payment_model] [tinyint] NULL
CONSTRAINT [PK_ssv5_results1200_load2] PRIMARYKEYCLUSTERED
([smart_search_result_id] ASC,
[SearchDate] ASC,
[smart_search_id] ASC)ON [SmartSearchPSchemeResults] (Searchdate)
)ON [SmartSearchPSchemeResults] (Searchdate)
And I got a staging table which is basically the same for just one month:
CREATE TABLE [dbo].[ssv5_results_load](
[smart_search_result_id] [bigint] NOTNULL,
[smart_search_id] [bigint] NOTNULL,
[provider_id] [tinyint] NOTNULL,
[smart_result_type_id] [bit] NOTNULL,
[smart_result_dmc_id] [smallint] NOTNULL,
[smart_result_dmc_code] [varchar](10)NOTNULL,
[smart_result_hotel_id] [int] NOTNULL,
[SearchDate] [smalldatetime] NOTNULL,
[smart_result_included] [varchar](1000)NULL,
[smart_result_excluded] [varchar](1000)NULL,
[smart_result_promotion] [nvarchar](1000)NULL,
[smart_result_completed] [tinyint] NULL,
smart_result_payment_model] [tinyint] NULL
CONSTRAINT [PK_ssv5_results1200_load2] PRIMARYKEYCLUSTERED
([smart_search_result_id] ASC,
[SearchDate] ASC,
[smart_search_id] ASC)ON [SS_Results_20090301]
)ON [SS_Results_20090301]
ALTER TABLE ssv5_results_load add constraint check_date
CHECK (searchdate >= '2009/03/01' AND searchdate < '2009/03/02')
searchdate >= '2009/03/01 and searchdate < '2009/03/02'
Finally, I load the data in there (just a few for test purpose):
INSERT
INTO Agoda_Smartsearch_v5_new.dbo.ssv5_results_load2SELECTTOP 1000 *
FROM Agoda_SmartSearch_V5.dbo.ssv5_results
WHERE SEARCHDATE >='2009/03/01'
AND SEARCHDATE <'2009/03/02'
ALTER
TABLE ssv5_results_load SWITCH TO Agoda_Smartsearch_v5_new.dbo.ssv5_results PARTITION 2And this is when the problem occurs:
Msg 4972, Level 16, State 1, Line 1
ALTER TABLE SWITCH statement failed. Check constraints or partition function of source table 'Agoda_Smartsearch_v5_new.dbo.ssv5_results_load' allows values that are not allowed by check constraints or partition function on target table 'Agoda_Smartsearch_v5_new.dbo.ssv5_results'.
Additional information:
fn id boundary id parameter id value
65540 1 1 2009-02-01 00:00:00.000
65540 2 1 2009-03-01 00:00:00.000
65540 3 1 2009-03-02 00:00:00.000
65540 4 1 2009-03-03 00:00:00.000
65540 5 1 2009-03-04 00:00:00.000
65540 6 1 2009-03-05 00:00:00.000
Can somone help me sort this out.
I feel like I'm pretty close to the problem. I don't understand how my data wouldn't match the values allowed by the partition considering all the effort to make sure that only the right data gets in the staging table.
Thanks in advance,
Nico
Need help in DMV query which pulls memory consumption
Hi All,
Does anyone has a query which tells me how much memory is being consumed by each session along with associated query text. Looking for something which tells me , this particular session_id/spid is using 'x' number of data pages and it is occupying 'y-MB' in
the buffer pool. If anyone has similar query, please share it. we are using sql 2012 and above sql instances.
Can we do this using sp_whoisactive?
Thanks,
Sam
ASCII in sql server
Hello,i new here,i not know if this topic is in correct place,please if not..move for me thanks
My question is :
How block ASCII in sql server ?
SQL Server Restore Failing with Error Read on "M:\MSSQL\My_FULL_Backup_20190924_010558.bak" failed: 1101(A tape access reached a filemark
I have been trying to restore one of our db for the past few days without any luck. I keep getting the below error. I tried the restore during peak hours, off peak hours both by accessing the backup via network and then moving the file to local server.
I have also run Restorefilelistonly and restoreheaderonly on the backup and all seems to be fine. There is no permissions issue.
Please see the error below and the screenshot from SQL Logs. I did not much help googling this issue.
1 percent processed.
2 percent processed.
3 percent processed.
4 percent processed.
5 percent processed.
6 percent processed.
7 percent processed.
8 percent processed.
9 percent processed.
10 percent processed.
11 percent processed.
12 percent processed.
13 percent processed.
14 percent processed.
15 percent processed.
16 percent processed.
17 percent processed.
18 percent processed.
19 percent processed.
20 percent processed.
21 percent processed.
22 percent processed.
23 percent processed.
24 percent processed.
25 percent processed.
26 percent processed.
27 percent processed.
28 percent processed.
29 percent processed.
30 percent processed.
31 percent processed.
32 percent processed.
33 percent processed.
34 percent processed.
35 percent processed.
36 percent processed.
37 percent processed.
38 percent processed.
39 percent processed.
40 percent processed.
41 percent processed.
42 percent processed.
43 percent processed.
44 percent processed.
45 percent processed.
46 percent processed.
47 percent processed.
48 percent processed.
49 percent processed.
50 percent processed.
51 percent processed.
52 percent processed.
53 percent processed.
54 percent processed.
55 percent processed.
56 percent processed.
57 percent processed.
58 percent processed.
59 percent processed.
60 percent processed.
61 percent processed.
62 percent processed.
63 percent processed.
64 percent processed.
65 percent processed.
66 percent processed.
67 percent processed.
68 percent processed.
69 percent processed.
70 percent processed.
71 percent processed.
72 percent processed.
73 percent processed.
74 percent processed.
75 percent processed.
76 percent processed.
77 percent processed.
78 percent processed.
79 percent processed.
80 percent processed.
81 percent processed.
82 percent processed.
83 percent processed.
84 percent processed.
85 percent processed.
86 percent processed.
87 percent processed.
88 percent processed.
89 percent processed.
90 percent processed.
91 percent processed.
92 percent processed.
93 percent processed.
94 percent processed.
95 percent processed.
96 percent processed.
97 percent processed.
98 percent processed.
Msg 3203, Level 16, State 1, Line 2
Read on "M:\MSSQL\My_FULL_Backup_20190924_010558.bak" failed: 1101(A tape access reached a filemark.)
Msg 3013, Level 16, State 1, Line 2
RESTORE DATABASE is terminating abnormally.
Problem connecting to a remote named instance with firewall enabled and browser service running
doubts on index rebuilds
Need some clarity on Index rebuilds.
1. Does Rebuilding a clustered idx, will rebuild all non-clustered idx's as well on that table? What is the locking behaviour during clustered idx REBUILD operation? Will the table is available for user access during rebuild?
2. if I choose rebuilding a specific non-clustered index then only that particular index will not be available but other structures i mean base table clustered idx is available for user access? Is that correct?
3. What is the best time to perform the index rebuilds. Reason, I am asking is, these indexes are very large indexes. I am seeing some performance issues, if this is run during week-days. The problem , few support engineers are blindly running index rebuild jobs if a user complains about db performance issue.
SQL Version : SQL 2012+ EE
Thanks,
Sam
Allocated Space not used when TraceFlag 692 not on.
I am observing unwanted behaviour with SQL2016. I would be very grateful if someone could explain it to me.
(Note - Despite the fact that I am not convinced this is a bug I am never-the-less putting this into the bugs section as none of the other sections seem at all appropriate.
Steps to Reproduce
1. Create a db - TestFlag692
2. Create a table within the db with the attached CreateTable.sql script.
3. Create an index on the table with the attached CreateIndex.sql script.
4. Run the app supplied in TableBloatExample.zip (Hit the Go button). What this does is to generate data for the table we have created and insert it into the table in chunks the size of which are determine by the ParmsForAnIndividualInsert. This is the number
of parameters that will be used when generating the INSERT Statement that is to be invoked (As the original setting is 2044 and there are four columns in the table this will result in 511 rows being sent to the database at a time. Run this with the setting
of 2044 and observe the results of running TableDataSizes.sql you will see something very similar to TestOutput511.jpg where the UnusedSpace will be <= 64kb.
5. Repeat Steps 1-4 (Either delete the original database, or run to a different database of your choice). Note - If you run to a different database of your choice then you will need to change the db name in the scripts and app. This time change the ParmsForAnIndividualInsert setting to 2048 (Divided by 4 this means that it will attempt to insert 512 rows at a time). Observe the results of running TableDataSizes.sql you will see something very similar to TestOutput512.jpg where the UnusedSpace can be quite large.
My question is why is there such a dramatic difference in UnusedSpace? Is this is a bug? and how do I prevent it?
Detect constraints in view of base table
Automatic back up or copy of database to another server
Hi everyone.
I have two servers, and I wanted to make one server as operating server (server1), and store back ups on another server(server2). Another approach is to copy database from server1 to server2 on daily basis. How it can be done?
When I tried to back up database with connecting to server1 from SSMS on server2, it saved back up on server1.
Regards,
Yerkhan
Replication - DistributionDB changing Drive
we have publisher server A & also configures distributor db also..
this distributor db in D: , we plan to move it to F: how to accomplish this?
we have transnational replication
server A (publisher & distributor) to another subscriber server B
Is below steps works?* Stop the Log Reader Agent and Distribution Agent
* ALTER DATABASE distribution SET OFFLINE
* Move the data and log file to the new location
* ALTER DATABASE distribution MODIFY FILE ( NAME = distribution , FILENAME = 'NewPath\distribution.mdf'
* ALTER DATABASE distribution MODIFY FILE ( NAME = distribution_log , FILENAME = 'NewPath\distribution.ldf'
* ALTER DATABASE distribution SET ONLINE
* Started the Log Reader Agent and Distribution Agent
CREATE DATABASE failed - perating system error 5(failed to retrieve text for this error. Reason: 15105)
I have following issue in one of our SQL Server environments.
Version: SQL Server 2008 R2
Issue: When I try to create a database in C:\databases folder, I get the following error. But, I can create databases in any other place (even in C: drive)
This might be a permission issue, but I couldn't figure out the exact reason.
Error:
CREATE FILE encountered operating system error 5(failed to retrieve text for this error. Reason: 15105) while attempting to open or create the physical file 'C:\databases\test.mdf'.
CREATE DATABASE failed. Some file names listed could not be created. Check related errors. (Microsoft SQL Server, Error: 5123)
Anyway,
1. I tried to run SSMS as administrator and it didn't work
2. Couldn't find any user access control on this folder.
References
http://stackoverflow.com/questions/11178536/create-file-encountered-operating-system-error-5failed-to-retrieve-text-for-thi
http://connect.microsoft.com/SQLServer/feedback/details/126562/misleading-error-message-while-attaching-the-file
http://boardreader.com/thread/Failed_to_create_a_database_with_error_C_m6yf__b40406a3-022a-4c31-9227-983fca13703d.html
Appreciate your comments and suggestions
Thankyou
Row insertion into table with more than 8060bytes
sample code:
create table t1
(
id int,
fname char(8000),
lname varchar(8000),
haddress varchar(8000)
)
go
insert t1
select 2,'r',replicate('s',500),replicate('h',19) --insert is successful
insert t1
select 2,replicate('s',8000),replicate('s',8000),'a11133333333333335w' --insert is successful
insert t1
select 2,'r',replicate('s',500),replicate('h',20) --gives error
insert t1
select 2,replicate('s',8000),replicate('s',8000),'a11133333333333335wa' --gives error
Result:
(1 row(s) affected)
(1 row(s) affected)
Msg 511, Level 16, State 1, Line 8
Cannot create a row of size 8061 which is greater than the allowable maximum row size of 8060.
The statement has been terminated.
Msg 511, Level 16, State 1, Line 11
Cannot create a row of size 8061 which is greater than the allowable maximum row size of 8060.
The statement has been terminated.
-----------------------
The first two INSERT statements are successful. Can somehelp help me understand why last two INSERT fails.
Regards
Santosh K
MS SQL Server DBA
igraph png not working on SQL Server 2019
Hi,
I made some tests with Graph Databases and was trying to use R services do create an image file of the graph. I'm not an R specialist but I was able to write an R script to create the image, it works very well on SQL Server 2017.
The R script:
exec sp_execute_external_script @language = N'R',
@script = N'
require(igraph)
g <- graph.data.frame(graphdf)
V(g)$label.cex <- 2
png(filename = "c:/R/plot1.png", height = 1200, width = 1200, res = 100);
plot(g, vertex.label.family = "sans", vertex.size = 40)
dev.off() ',
@input_data_1 = N'select LikeMember.MemberName as LikeMember, LikedMember.MemberName as LikedMember from dbo.ForumMembers as LikeMember, dbo.ForumMembers as LikedMember, Likes
where Match(LikeMember-(Likes)->LikedMember)',
@input_data_1_name = N'graphdf'
GO
It works perfectly in SQL Server 2017 but I couldn't make it work in SQL Server 2019. The error message is:
Error in png(filename = "c:/R/plot1.png", height = 1200, width = 1200, :
unable to start png() device
Calls: source -> withVisible -> eval -> eval -> png
In addition: Warning messages:
1: In png(filename = "c:/R/plot1.png", height = 1200, width = 1200, :
unable to open file 'c:/R/plot1.png' for writing
2: In png(filename = "c:/R/plot1.png", height = 1200, width = 1200, :
opening device failed
Error in execution. Check the output for more information.
Error in eval(ei, envir) :
Error in execution. Check the output for more information.
Calls: runScriptFile -> source -> withVisible -> eval -> eval -> .Call
Execution halted
Although the error message seems obvious, I already checked the permissions on the folder, the user of the services (SQL Server and Launchpad) and even used the audit over the folder but could not identify how to solve this problem.
Any idea?
Thank you!
Dennes
Why I can't find the .bak file in SSMS restore window
HI,
I know this question must be very silly, but I just can't find any setting anywhere.
The scene is, when I try to restore a .bak database file, in SSMS restore window. If I place the .bak file in the C root folder. I can see it. But if I put in anywhere else, say, on desktop. I just can't find it in SSMS.
Would anyone tell me what should be done, or how I can do the restore?
Distribution Database -SQL replication- changing database owner 'sa' to some
team,
we have transnational replication & the distribution database owner is in "sa".
while i try to change distribution database owner to some other am getting
Error:
Set owner failed for Database 'distribution'. (Microsoft.SqlServer.Smo),Cannot change the owner of the master, model, tempdb or distribution database. (Microsoft SQL Server, Error: 15109)