Quantcast
Channel: SQL Server Database Engine forum
Viewing all 12554 articles
Browse latest View live

SQL SERVER 2016 SP2 CU3 high CPU

$
0
0

We have SQL SERVER 2016 Standard Edition SP2 CU3 installed on it recently we noticed that cpu is treding very high so after reading online there was CCC audit introduced in c2 which was fixed in cu3 and that is now disabled however, do you guys advise that we should enable the Traceflag 3427 on SQL SERVER 2016 SP2 CU3 which possible can help to control the high cpu usuage.  Please advise on this many thanks 

bcp/or BULK INSERT large file with different header delimiter than data row delimiter

$
0
0

I have to bulk load or bcp a large file (approx. 10 GB) which has "LF" for the header row delimiter and "CRLF" for all the data rows delimiter. I use SQL 2017 with the new "csv" functionality and it fails

BULK INSERT csvtable FROM 'C:\Temp\bulkload\CSVfile.txt' WITH (FORMAT = 'CSV', FIELDTERMINATOR = ',',  ROWTERMINATOR =  '0x0A',CODEPAGE=65001) .

I tested to Powershell the file and remove the first row , that works but wondering if do not introduce altering the file.

(Get-Content $file|Select-Object-Skip1)|Set-Content $file

Is there any way to handle in bcp or BULK INSERT different header delimiter than data rows delimiters?

Thank you,

Operating system error 170 : resource in use error on SQL Server 2012 Cluster on VM ware 6.5

$
0
0

Hi All,

we need your help in analyzing one of our ongoing issue.From last few days ,we could see below events are triggering on all  SQL server cluster server and DB's are  going to suspect mode and causing service disruption. Please advise,what can cause this issue ? 

FYi...our VM ware version is 6.5 and there is recent tools upgrade activity on all cluster servers.

Here is the complete SQL logs :

2018-06-23 00:24:00.720 spid1s       Error: 17053, Severity: 16, State: 1.
2018-06-23 00:24:00.720 spid1s       SQLServerLogMgr::LogWriter: Operating system error 170(The requested resource is in use.) encountered.
2018-06-23 00:24:00.730 spid1s       Write error during log flush.
2018-06-23 00:24:00.750 spid53       Error: 9001, Severity: 21, State: 4.
2018-06-23 00:24:00.750 spid53       The log for database 'msdb' is not available. Check the event log for related error messages. Resolve any errors and restart the database.
2018-06-23 00:24:00.800 spid53       Database msdb was shutdown due to error 9001 in routine 'XdesRMFull::CommitInternal'. Restart for non-snapshot databases will be attempted after all connections to the database are aborted.
2018-06-23 00:24:00.880 spid25s      Error: 17053, Severity: 16, State: 1.
2018-06-23 00:24:00.880 spid25s      fcb::close-flush: Operating system error (null) encountered.
2018-06-23 00:24:00.880 spid25s      Error: 17053, Severity: 16, State: 1.
2018-06-23 00:24:00.880 spid25s      fcb::close-flush: Operating system error (null) encountered.
2018-06-23 00:24:01.020 spid25s      Starting up database 'msdb'.
2018-06-23 00:24:01.290 spid25s      9 transactions rolled forward in database 'msdb' (4:0). This is an informational message only. No user action is required.
2018-06-23 00:24:01.300 spid25s      SQLServerLogMgr::FixupLogTail (failure): alignBuf 0x0000000019CAD000, writeSize 0x9e00, filePos 0x766200 
2018-06-23 00:24:01.300 spid25s      blankSize 0x3c0000, blkOffset 0x341, fileSeqNo 7642, totBytesWritten 0x0
2018-06-23 00:24:01.300 spid25s      fcb status 0x100042, handle 0x0000000000001888, size 1048 pages 
2018-06-23 00:24:01.300 spid25s      Error: 17053, Severity: 16, State: 1.

Regards,

Naren

Deleted records from table

$
0
0

how to find deleted records from a table.

Req:  TableA & TableB

find deleted records from TableA  (some one deleted records from tableA dayago /  now same records needs to delete in TableB) 

ETL load process locked by a system query running a create index???

$
0
0

Hi,

I suffered a strange issue during the loading of data using SSIS into a clustered columnstore index table 

SQL 2016 Enterprise edition used.

in the middle of the loading, my insert were locked by a create index command executed by the system ????

it was not a user query or user connection.

its a random behavior I suffered it 2 times in the past 2 months.

any idea of the reason of this?

is the system doing some background tasks on the clustered columnstore index which lock it?

SQL Failover Cluster - SQL cluster installation

$
0
0

Hi All,

My customer told me to build SQL Failover Cluster (SQL cluster installation) on top of windows. As per my understanding, SQL Failover Cluster (SQL cluster installation) means, protecting DB by configuring HA (SQL Alwayson or DB mirroring or LOG shipping or Replication). Is my understanding is correct? 

Parallel redo is started for database 'ReportServerTempDB' with worker pool size [2].

$
0
0

Hi All,

We notice this error in the SQL Server error log frequently, the SQL server is running with 2017  with patch 2017.140.2002.14.

I dint find any answers in any blog, might be due to latest version and release.

Do we have any work around for this or do we need to wait for SP1 to release.

Thanks in advance.


Regards, Pradyothana DP. Please Mark This As Helpful if it helps to solve your issue. ========================================================== https://social.technet.microsoft.com/Profile/pradyothanadp http://www.dbainhouse.blogspot.in/

temporal or not temporal

$
0
0

Hi we run 2016 enterprise. I'm contemplating a star schema with temporal turned on. vs the old fashioned begin and end dates without temporal.  Or even recording historic data in a separate database.  My recovery is simple.  I'll probably turn rcsi on.  don't even know yet if that's compatible with temporal.

My core (fact) tables tend to be in the 60-100 million row range.  And there will likely be 5 of them.  Most of my dims (50?) are low volume (<50 rows) but 3 or 4 of them are also in the 60-100 million row range and seem more like hybrid fact tables than pure dims.

What are the downsides of temporal tables?  Why does there always seem to be some mention of memory tables in the temporal discussion but really no explanation why?  I'd probably never physically delete a record but that brings up the question if i'll be allowed to programmatically set the end date in those scenarios.  I'll probably want a row version on every row of every table so my downstream consumers can more easily detect changes without relying on the temporal history nor date times which I've always considered somewhat porous for detecting changes.  temporal history for me would serve 3 purposes...recovery/explaining things, "as of" visuals for more sophisticated users/queries and insulating the average user from extra joins when all they really want is what things look like as of today.   

generally speaking, neither facts nor dims change a lot but during a year 3-4 million inserts can occur on facts and higher volume hybrid dims. 


Index selection anomalies. How syntax impact on index selection.

$
0
0

Hello,

I try to optimize some process, which include many large SQL queries with many operators Cluster Index Seek on certain table. I found out that set of columns which is used by all these operators (from all these queries) is about half of all columns of the table.

In this case, it is good idea to reduce size of used index by creation of Non-Cluster Index which has the same key(s) like Cluster Index but contains only necessary (for this process) columns in INCLUDES.

(Note, that in most cases Cluster Index Seek and Non-Cluster Index Seek have the same operation cost on execution plan and hence they take the same time. It is true, but when optimizer turns on mechanism ‘read ahead’ the size of used index significantly impacts on performance. Surely, it is not taken into account in execution plans.)

I created index and assumed that optimizer will choose Non-Cluster index for seek operation instead of Cluster Index seek for all cases, because Non-Cluster index has less size for each record or because it is last created acceptable index. In worst case, I expected that optimizer will remain Cluster Index everywhere. But I did not expect that optimizer can use different operators (even in one query).

After I created the Non-Cluster index, I have seen that new index is used only in several places of execution plan. In others places, optimizer could use the Non-Cluster Index, but it did not do it. It was very bad because Cluster Index Seek operators did not use the data, which was cached by Non-Cluster index and vise versa. It leaded to performance degradation.

I found simple cases, which show these anomalies of index selection. To show it use AdventureWorks201 database  (https://docs.microsoft.com/en-us/sql/samples/adventureworks-install-configure?view=sql-server-2017). We will look at index selection on table Person.Person. Further, we need Non-Cluster Index

CREATE UNIQUE NONCLUSTERED INDEX [IX_BusinessEntityID_FirstName] ON [Person].[Person]
(
	[BusinessEntityID] ASC
)
INCLUDE ([FirstName]) 
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

and run the following queries

SELECT em.FirstName FROM [HumanResources].[EmployeeDepartmentHistory] ed
LEFT JOIN Person.Person em ON em.BusinessEntityID = ed.BusinessEntityID 
WHERE ed.DepartmentID = 5

SELECT em.FirstName FROM [HumanResources].[EmployeeDepartmentHistory] ed
LEFT JOIN (SELECT * FROM Person.Person) em ON em.BusinessEntityID = ed.BusinessEntityID 
WHERE ed.DepartmentID = 5

SELECT em.FirstName FROM [HumanResources].[EmployeeDepartmentHistory] ed
LEFT JOIN Person.Person em ON em.BusinessEntityID = ed.BusinessEntityID 
WHERE ed.DepartmentID = 5 AND ed.BusinessEntityID = 250

These queries correspond to the following execution plans

  |--Nested Loops(Left Outer Join, OUTER REFERENCES:([ed].[BusinessEntityID]))
       |--Index Seek(OBJECT:([AdventureWorks2017].[HumanResources].[EmployeeDepartmentHistory].[IX_EmployeeDepartmentHistory_DepartmentID] AS [ed]), SEEK:([ed].[DepartmentID]=(5)) ORDERED FORWARD)
       |--Index Seek(OBJECT:([AdventureWorks2017].[Person].[Person].[IX_BusinessEntityID_FirstName] AS [em]), SEEK:([em].[BusinessEntityID]=[AdventureWorks2017].[HumanResources].[EmployeeDepartmentHistory].[BusinessEntityID] as [ed].[BusinessEntityID]) ORD
 |--Nested Loops(Left Outer Join, OUTER REFERENCES:([ed].[BusinessEntityID]))
       |--Index Seek(OBJECT:([AdventureWorks2017].[HumanResources].[EmployeeDepartmentHistory].[IX_EmployeeDepartmentHistory_DepartmentID] AS [ed]), SEEK:([ed].[DepartmentID]=(5)) ORDERED FORWARD)
       |--Compute Scalar(DEFINE:([Expr1004]=[AdventureWorks2017].[Person].[Person].[FirstName]))
            |--Clustered Index Seek(OBJECT:([AdventureWorks2017].[Person].[Person].[PK_Person_BusinessEntityID]), SEEK:([AdventureWorks2017].[Person].[Person].[BusinessEntityID]=[AdventureWorks2017].[HumanResources].[EmployeeDepartmentHistory].[BusinessEnt
  |--Nested Loops(Left Outer Join)
       |--Index Seek(OBJECT:([AdventureWorks2017].[HumanResources].[EmployeeDepartmentHistory].[IX_EmployeeDepartmentHistory_DepartmentID] AS [ed]), SEEK:([ed].[DepartmentID]=(5) AND [ed].[BusinessEntityID]=(250)) ORDERED FORWARD)
       |--Clustered Index Seek(OBJECT:([AdventureWorks2017].[Person].[Person].[PK_Person_BusinessEntityID] AS [em]), SEEK:([em].[BusinessEntityID]=(250)) ORDERED FORWARD)

On first execution plan, you can find our Non-Cluster Index seek, on other plans - Cluster Index seek. Note, that differences between first and second queries is only in syntax. After some experiments, I can say that for first case optimizer takes Non-Cluster Index, which was created first, for other cases optimizer takes only Cluster Index.

Questions are the following:

Why optimizer choose index this way? What are differences between these cases for mechanism of index selection?

How can I impact on this selection? (using of hints is not acceptable solution)

How can I fix this behavior to solve my issue?


Thank you in advance.

grant sql service account read/write access to that folder(even i gave permision for that folder but still i am getting that error

$
0
0
grant sql service account read/write access to that folder(even i gave permision for that folder but still i am getting that error

Procedure take more time

$
0
0

sometimes particular SP take more time.  ( no blocking / deadlocks happens)

what are the workaround ? how to identify a cause? 

normally takes 10 ~ 15min   , some times takes 2hrs. ( but data result volume not high).

BUG with TableDiff using in SQL Server?

$
0
0
I have 2 tables on different sql server instances but with same structure(same names and same data types). each table has 10M rows.Instance A as the base, instance B as the destination.

They should have same data, but actually not. so I use tablediff to generate script for the different rows, then run it on the destination B.

It generates about 200 scripts,each script has 3000 statements. and I find one strange thing, sometimes it has deleting script first, and then inserting script for same record. and I have compared the row on 2 instances, they actually do have the same record.

So my question is, why it has this kind of behavior?why it could not skip this kind of compare?

Prioritizing TempDB log files

$
0
0
I have a special circumstance why I want to have two TempDB log files. Our Production SQL Server (SQL2012SP4) was over engineered. The physical boxes (clustered) have 515GB of memory each, 450GB of which are allocated to SQL server. I ran some metrics against peak-load times by totaling the input buffer pages, and determined that SQL was really only using ~224GB. I want to use some of that excess RAM memory to create a 128GB vRam disk, on which I want to put the default TempDB_Log1.ldf file. For safety sake, I am creating a secondary TempDB_Log2.ldf file on the physical drive for any time the vRam disk overflows. My question is, how do I prioritize the .ldf files so that the SQLOS knows to use the .ldf file on the vRam drive first?

Brandon Forest SQL Server DBA

Rename the Partitioned table in using sp_rename command or GUI.

$
0
0

Hi ,

Could you please suggest me on below query.

Can we rename the Partitioned table in using sp_rename  command or GUI in SQL server 2014 Version ?

sp_rename "db_name.old_table_name","new_table_name"

I seen the below article, It is very good. 

https://blogs.msdn.microsoft.com/docast/2015/12/15/sql-server-impact-of-renaming-the-partitioned-table-on-data/

But here my query is why can't we use the above query to rename partitioned table. what is the Technical reason behind it.

My views are below. Kindly correct me, If I am thinking in other direction.


Object id is referred by DB engine, and object name is referred by user(here admin or developer).

partition Logic  is work on Partition schema and partition function.

So in this scenario  partition schema and function  is the same and only changing is table name.

Kindly Suggest.

Regards,

Trinadh.

Permutation and combination with inclusion and exclusion

$
0
0

Hi, Given a column of values ('Black', 'White', 'Orange') with sequence numbers 1,2,3 respectively, i need to find the permutations and combinations such as below.

Colortable 
ColorSequence
Black1
White2
Orange3
As a result 
InNotIn
BlackWhite,Orange
WhiteBlack,Orange
OrangeBlack,White
Black,WhiteOrange
Black,OrangeWhite
Orange,WhiteBlack
Black,White,OrangeNull

 


Bishnupriya Pradhan


SQL in memory question

$
0
0

hi, 

i know that in sql server in-memory oltp, data will be in memory but since memory is wipe out after restart, the table will be empty again so how to make it permanent even after restart like other tables? h

also,are the data pages flushed out from memory if the table is permanent?

I am learning this feature so need help. thanks.

Detached SQL Server 2008 R2 Database with FILESTREAM won't re-attach

$
0
0

I detached a production database to try and resolve an issue with a truncated log file that would not shrink. I copied the log file to a backup location and tried to re-attach the database expecting to get the prompt about re-creating the transaction log file. The database would not attach it referred to the filestream location referenced in the primary file as being incorrect.

I copied the backed up transaction log back and tried again but got the same error. Does anybody have a solution that does not involve restoring the database backups?

I did restore a backup but when I do a DBCC checkdb it shows the filestream as offline.

MSBUILD and automated releases

$
0
0

All,

I'm posting this question here even though it is more of a AzureDevOps question but nevertheless it is related to SQLServer and I could not find an exclusive forum for AzureDevOps.

We have to implement CI/CD for our SQLServer 2012 database releases. We used to use TFS but now we have migrated to VSTS platform and now we are working on the Database CI/CD design. We decided that we will be using the State-Based approach using the SQLPackage to deploy the differential scripts from the project and in this Phase I of our project, we are not considering Unit Testing.

We have identified two tools primarily to use in our pipeline ie, SQLPackage and MSBuild. We will use SQLPackage to build the Test Bed for the database against which we will be targeting the planned changes and we will be using MSBuild to create off of the database solution/Project that the developers would check in. We will eventually deploy the changes using SQLPackage as it can apply the differences against the target environment (Test Build, Stage and Prod).

In the Publish phase of the SQLPackage, we will put in lot of restrictions such as

[1] Ignore Logins

[2] Ignore Users

[3] Ignore Database creation

I just wanted to hear from others their experiences and lessons learnt.. Let me know if I'm missing anything.

Thanks,

rgn


Collation SQL_Latin1_General_CP1_CI_AS vs Latin1_General_BIN2

$
0
0

Change database / column collation from SQL_Latin1_General_CP1_CI_AS vs Latin1_General_BIN2

1. what's the sorting difference?

2. what's the character size difference ?

3. what's the steps the change the collation ? for database it should be easy, for column collation , how to change at once?

4. Are there character conversion need ?will there be character corruption during the collation change/?

Grant create index in sql server 2012

$
0
0

Hi

how can get grant create index on view to user?!

Viewing all 12554 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>