Quantcast
Channel: SQL Server Database Engine Forum
Viewing all 15872 articles
Browse latest View live

SQLPackage Timeout on SQL Server 2014 with TF 4199

$
0
0

Hi all,

Since we have migrated to SQL 2014 SP1, we figured out that our application was experiencing the Cardinality Estimator bug.(See this link)

After applying this TF, sqlpackage is now experiencing timeout on this query:

SELECT * FROM (
SELECT
        SCHEMA_NAME([o].[schema_id])    AS [SchemaName],
        [si].[object_id]                AS [ColumnSourceId],
        [o].[name]                      AS [ColumnSourceName],
        [o].[type]                      AS [ColumnSourceType],
        [ic].[column_id]                AS [ColumnId],
        [c].[name]                      AS [ColumnName],
        [si].[index_id]                 AS [IndexId],
        [si].[name]                     AS [IndexName],
        [ds].[type]                     AS [DataspaceType],
        [ds].[data_space_id]            AS [DataspaceId],
        [ds].[name]                     AS [DataspaceName],
        [si].[fill_factor]              AS [FillFactor],
        [si].[is_padded]                AS [IsPadded],
        [si].[is_disabled]              AS [IsDisabled],
        [si].[allow_page_locks]         AS [DoAllowPageLocks],
        [si].[allow_row_locks]          AS [DoAllowRowLocks],
        [sit].[cells_per_object]        AS [CellsPerObject],
        [sit].[bounding_box_xmin]       AS [XMin],
        [sit].[bounding_box_xmax]       AS [XMax],
        [sit].[bounding_box_ymin]       AS [YMin],
        [sit].[bounding_box_ymax]       AS [YMax],
        [sit].[level_1_grid]            AS [Level1Grid],
        [sit].[level_2_grid]            AS [Level2Grid],
        [sit].[level_3_grid]            AS [Level3Grid],
        [sit].[level_4_grid]            AS [Level4Grid],
        [sit].[tessellation_scheme]     AS [TessellationScheme],
        [s].[no_recompute]              AS [NoRecomputeStatistics],
        [p].[data_compression]          AS [DataCompressionId],
        CONVERT(bit, CASE WHEN [ti].[data_space_id] = [ds].[data_space_id] THEN 1 ELSE 0 END)
                                        AS [EqualsParentDataSpace]
FROM
        [sys].[spatial_indexes]          AS [si] WITH (NOLOCK)
        INNER JOIN [sys].[objects]       AS [o] WITH (NOLOCK) ON [si].[object_id] = [o].[object_id]
        INNER JOIN [sys].[spatial_index_tessellations] [sit] WITH (NOLOCK) ON [si].[object_id] = [sit].[object_id] AND [si].[index_id] = [sit].[index_id]
        INNER JOIN [sys].[data_spaces]   AS [ds] WITH (NOLOCK) ON [ds].[data_space_id] = [si].[data_space_id]
        INNER JOIN [sys].[index_columns] AS [ic] WITH (NOLOCK) ON [si].[object_id] = [ic].[object_id] AND [si].[index_id] = [ic].[index_id]
        INNER JOIN [sys].[columns]       AS [c] WITH (NOLOCK) ON [si].[object_id] = [c].[object_id] AND [ic].[column_id] = [c].[column_id]
        INNER JOIN [sys].[objects]       AS [o2] WITH (NOLOCK) ON [o2].[parent_object_id] = [si].[object_id]
        INNER JOIN [sys].[stats]         AS [s] WITH (NOLOCK) ON [o2].[object_id] = [s].[object_id] AND [s].[name] = [si].[name]
        INNER JOIN [sys].[partitions]    AS [p] WITH (NOLOCK) ON [p].[object_id] = [o2].[object_id] AND [p].[partition_number] = 1
        LEFT  JOIN [sys].[indexes]       AS [ti] WITH (NOLOCK) ON [o].[object_id] = [ti].[object_id]
        LEFT JOIN [sys].[tables]         AS [t] WITH (NOLOCK) ON [t].[object_id] = [si].[object_id]
WHERE [si].[is_hypothetical] = 0
        AND [ti].[index_id] < 2
        AND OBJECTPROPERTY([o].[object_id], N'IsSystemTable') = 0
        AND ([t].[is_filetable] = 0 OR [t].[is_filetable] IS NULL)
        AND ([o].[is_ms_shipped] = 0 AND NOT EXISTS (SELECT *
                                        FROM [sys].[extended_properties]
                                        WHERE     [major_id] = [o].[object_id]
                                              AND [minor_id] = 0
                                              AND [class] = 1
                                              AND [name] = N'microsoft_database_tools_support'
                                       ))
) AS [_results]

Does some of you have experienced this issue also? And how have you corrected it?

Cheers,

Jeremy


Backups in both nodes?? Always On

$
0
0

Dear all,

Primary Platform: SQL 2014 Sp1

I am confused with one of my Always On in prod and I wonder what am I missing.

My Always Group is defined: Syncronous (Availability Mode) and Automatic (Failover Mode)

On Backup Preferences for this Always Group we have “Secondary Only”

Nonetheless day in day out Backups are done in both nodes, primary and secondary through our third-part backup tool.

 

This select confirm different values(0/1) depending in which node. It confirms that the setting “Secondary Only” works well:

 

 

SELECT [master].sys.fn_hadr_backup_is_preferred_replica('MyDb')

 

And now, is there any reason for doing backups in both nodes?In my opinion, it does not make any sense.

 

In node 1 (primary) every hour is performed a LOG BACKUP and, in node 2 (secondary), MUST and MUST NOT NOW full backups.

 

Thanks indeed for your comments and suggestions!!

Tempdb into several files

$
0
0

Dear all,

Question is easy. I am running different clusters and standalones in UAT/TEST(Azure)/PROD with SQL Server 2014. One of them was configured for using same number of files = same number of cores.

Nonetheless, it has been done without analysis on GAM/SGAM/PFS pages on the original TEMPDB. It was deployed from the scratch with 8 TEMPDB. I attach you a very useful thread on colleagues discuss on that:

Tempdb contention old thread

My question, it does hurt? It does hurt if you split your tempdb in files when it's really not necessary upon analysis?

I am totally disagree to do or apply things or solutions without tests or analysis, but the reality is different, we have not time for do all the "exercises" 

Thanks for your comments

Is there a way to associate a description with database snapshot?

$
0
0
Is there a way to associate a description with database snapshot?

I usually name snapshots using original database name and timestamp:

DBName-05-27-2016_1018

I would like to be able to associate a comment like "Before executing schema update scripts related to feature NNN" with a snapshot.

This is something that I could put in database extended properties but since snapshot is read-only it is not possible after it is created and it doesn't look like extended properties can be specified as a part of snapshot creation. Making these comments a part of snapshot name is ugly.

Is there any other way to associate a metadata with database snapshot when it is created? Of course I can maintain a table in separate utility database just for this but this is not too convenient.

FILESTREAM error at server startup

$
0
0

When one of our SQL Server instances starts up I am getting the following errors in the log:

07/04/2016 08:21:59 FILESTREAM: effective level = 0, configured level = 2, file system access share name = 'MSSQLSERVER'.
07/04/2016 08:21:59 FILESTREAM feature could not be initialized. The Windows Administrator must enable FILESTREAM on the instance using Configuration Manager before enabling through sp_configure.
07/04/2016 08:21:59 Error: 5597, Severity: 16, State: 2.

However the impacted SQL Server service has the configuration:

If I subsequently try to enable this within SQL Server I get the error:

Prior to this problem, the most recent restart of SQL Server had the following message in the SQL errorlog:

05/04/2016 01:04:33 FILESTREAM: effective level = 2 (remote access enabled), configured level = 2, file system access share name = 'MSSQLSERVER'.

and everything worked fine.

For additional information, these databases are participating in an AlwaysOn Availability Group however the non-FILESTREAM databases have all started successfully.

Can anyone assist?

Thanks for your help.

Collation conflict

$
0
0

i updated the sql server 2012 to the sp3 ,

after that i getting the error as "

Cannot resolve the collation conflict between "Latin1_General_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation " in most of the tables.

how to rectify the collation overall by database wise 


GOVINDARAJ P

Optimizer doing extra seek for unused column

$
0
0

I have a table which has a number of columns including these:

  start_time decimal(10, 2) NOT NULL,
  duration decimal(10, 2) NOT NULL,
  end_time AS (start_time+duration) PERSISTED,

Duration is more useful for some queries, end_time for others. The main query in the system uses a particular non-clustered index which has both start_time and end_time in the key (since they are used in conditions) but does not include duration since the query does not refer to it at all. However, in some cases (not all) the optimizer adds an extra key lookup on the table's clustered index solely for the purpose of getting the duration column (according to the plan XML) and then does a nested loop join with the data returned by the seeks on the non-clustered index. Needless to say this is inefficient and I would like it to not do this.

My question is - why would the optimizer think it needs the column? The query is far too large to paste in here, but I have checked it and the duration column is really not referenced at all. As far as I understand it there should be no issues with using an index on a persisted computed column, and just in case I verified that all the settings allowing general use of indexes on computed columns (ANSI_NULLS, etc.) are set.

Microsoft SQL Server, Error: 233

$
0
0

Hi,

   While connecting the SQL server 2012 from server  itself using SSMS with remote connection getting following error.

--------------------------------------------

"A connection was successfully established with the server, but then an error occurred during the login process. 
(provider: SSL Provider, error: 0 - No process is on the other end of the pipe.)
 (Microsoft SQL Server, Error: 233)"

-------------------------------------------

notice :

1. Named pipe and TCP/IP are enabled ...Checked by SS Configuration Manager.

2. Browser service is running.

So Please advice a solution in this regard.

With Thanks 

Naseer.


SQL Server Database migration

$
0
0

HI All,

We are planning to move few databases from one server to other server by backup and restore method.  

1) To ensure no write operation during migration activity Please let us know the options we can have.

2) if we can set the databases in read only mode and take a backup and restore on new server do we need to ensure anything else?

Regards,

Varu

Database configuration size

$
0
0

Hi guys,

I am struggling with one particular db, let's say L1. The developer is moving data from one db to L1. I am talking about millions rows, so I had to set up a lot of space for the database. This is the configuration:

Rows..Initial Size 1000000 Autogrowth By 10000 MB Limited to 1400000 MB

Log Not Applicable Initial size 10753 Autogrowth By 256 MB Limited to   2097152

Simple recover (it is not a production database, so no really care about the log).

Any advice?

Thanks

NopCommerce Microsoft Web App Gallery- SA login falied

$
0
0

Hi,

I'm trying to install Ecommerce on my local system and it says login failed for sa although I'm using correct password

How can I improve this query for getting LOB datatypes as well?

$
0
0

Dear all,

I'm using this query for reindexing according fragmentation levels it run either REORGANIZE or REBUILD.

It runs properly.. till it find one index with LOB datatype and aborts everything:

An online operation cannot be performed for index 'I_175ITEMIDX' because the index contains column 'NOTES' of data type text, ntext, image or FILESTREAM. For a non-clustered index, the column could be an include column of the index. For a clustered index, the column could be any column of the table. If DROP_EXISTING is used, the column could be part of a new or old index. The operation must be performed offline.

How can I improve the query for indentifying all those indexes with LOB datatypes and put the tail "ONLINE=OFF"?

DECLARE @preferredReplica int

set nocount on

SET @preferredReplica = (SELECT [master].sys.fn_hadr_backup_is_preferred_replica('MyDb'))

IF (@preferredReplica = 0)

BEGIN

declare @fragmentation as table (
database_name sysname, [schema_name] sysname, table_name sysname, index_name sysname
, avg_fragmentation_in_percent decimal (28,2), avg_page_space_used_in_percent decimal (28,2)
, page_count bigint, record_count bigint, fragment_count bigint
, recommendation nvarchar(4000)
)
declare @database_name sysname
declare @query nvarchar(max)
declare @min_frag_rebuild int
declare @min_frag_reorganize int
declare @min_fill_rebuild int
declare @min_fill_reorganize int
declare @min_size int
declare @maxdop int


/*********************************************************************************************************************/
set @min_frag_rebuild = 25 -- More than 25% of fragmentation --> Rebuild
set @min_frag_reorganize = 10 -- More than 10% of fragmentation --> Reorganize
set @min_fill_rebuild = 60 -- Minimum fill ratio to rebuild
set @min_fill_reorganize = 75 -- Minimum fill ratio to reorganize
set @min_size = 100 -- Minimum index size to maintain the index
set @maxdop = (select cpu_count from sys.dm_os_sys_info) /8 -- Number of processors to be used for the rebuild
/*********************************************************************************************************************/

IF (SELECT OBJECT_ID('tempdb..#db')) IS NOT NULL
DROP TABLE #db;



SELECT d1.[name] into #db
FROM sys.databases d1
where d1.state_desc = 'ONLINE' and is_read_only = 0
and  database_id > 4  AND D1.NAME IN('MyDb')

DECLARE c_databases CURSOR read_only FOR
SELECT [name] FROM #db
OPEN c_databases
FETCH NEXT FROM c_databases
into @database_name
WHILE @@FETCH_STATUS = 0
BEGIN
set @query = N'
with dt as (
SELECT
index_id, object_id, database_id
, MAX(avg_fragmentation_in_percent) avg_fragmentation_in_percent, MAX(avg_page_space_used_in_percent) avg_page_space_used_in_percent
, MAX(page_count) page_count, MAX(record_count) record_count, MAX(fragment_count) fragment_count
from sys.dm_db_index_physical_stats (DB_ID('''+ @database_name +'''), NULL, NULL, NULL, NULL)
where ( avg_fragmentation_in_percent > ' + convert(char(3), @min_frag_reorganize) +'
or avg_page_space_used_in_percent < ' + convert(char(3), @min_fill_reorganize) + ')
and page_count > ' + convert(char(10), @min_size) + '
GROUP BY index_id, object_id, database_id
)
SELECT
db_name(database_id) database_name, s.name schema_name, t.name table_name, i.name index_name
, dt.avg_fragmentation_in_percent, dt.avg_page_space_used_in_percent, page_count, record_count, fragment_count
, case
when ( avg_page_space_used_in_percent < ' + convert(char(3),@min_fill_rebuild) +
' or avg_fragmentation_in_percent > ' + convert(char(3),@min_frag_rebuild) +
') then ''ALTER INDEX '' + QUOTENAME(i.name)+ '' ON '+ QUOTENAME(@database_name) + '.'' + QUOTENAME(s.name) +''.''+ QUOTENAME(t.name) +'' REBUILD ''
else ''ALTER INDEX '' + QUOTENAME(i.name)+ '' ON '+ QUOTENAME(@database_name) + '.'' + QUOTENAME(s.name) +''.''+ QUOTENAME(t.name) +'' REORGANIZE ''
end SENTENCIA_RECOMENDADA
FROM dt
INNER JOIN '+ QUOTENAME(@database_name) + '.sys.indexes i
ON dt.object_id = i.object_id and dt.index_id = i.index_id
INNER JOIN '+ QUOTENAME(@database_name) + '.sys.tables t
ON i.object_id = t.object_id
INNER JOIN '+ QUOTENAME(@database_name) + '.sys.schemas s
ON t.schema_id = s.schema_id
WHERE dt.index_id <> 0
ORDER BY database_name, s.name, t.name, i.name'
insert into @fragmentation (
database_name, [schema_name], table_name, index_name
, avg_fragmentation_in_percent, avg_page_space_used_in_percent
, page_count, record_count, fragment_count
, recommendation)
execute(@query)
FETCH NEXT FROM c_databases
into @database_name
END
CLOSE c_databases
DEALLOCATE c_databases
DROP TABLE #db

-- Get the fragmentation report
select * from @fragmentation

-- Defragment the indexes
if exists(select 1 from @fragmentation)
begin
DECLARE cursorBBDD_new CURSOR read_only fast_forward forward_only FOR
select database_name, [table_name], index_name, recommendation from @fragmentation
OPEN cursorBBDD_new
declare @databaseName sysname
declare @tableName nvarchar(100)
declare @Recommendation nvarchar(1024)
declare @Recommendation_new nvarchar (1024)
declare @indexname nvarchar(20)
FETCH NEXT FROM cursorBBDD_new
into @databaseName, @tableName, @indexname, @Recommendation
WHILE @@FETCH_STATUS = 0
BEGIN
-- Try to do it online and failback to offline mode if it is not possible
BEGIN TRY
IF (patindex('%REBUILD%',@Recommendation) <> 0 )
set @Recommendation_new='use ' + @databaseName + ';' + @Recommendation + 'WITH (ONLINE=ON, MAXDOP=' + CAST(@maxdop as varchar(10)) + ')'
ELSE
set @Recommendation_new='use ' + @databaseName + ';' + @Recommendation

exec (@recommendation_new)
print @Recommendation_new
END TRY
BEGIN CATCH
IF (patindex('%REBUILD%',@Recommendation) <> 0 )
set @Recommendation_new='use ' + @databaseName + ';' + @Recommendation + 'WITH (ONLINE=OFF, MAXDOP=' + CAST(@maxdop as varchar(10)) + ')'
ELSE
set @Recommendation_new='use ' + @databaseName + ';' + @Recommendation
-- Execute the command and then print it
exec (@recommendation_new)
print @Recommendation_new
END CATCH
FETCH NEXT FROM cursorBBDD_new
into @databaseName, @tableName, @indexname, @Recommendation
END
CLOSE cursorBBDD_new
DEALLOCATE cursorBBDD_new
end

end


This query give us info about datatypes:

select o.name objectname, i.name indexname, c.name as columnname, t.name, i.type_desc
from sys.objects o
join sys.indexes i on i.object_id = o.object_id
join sys.index_columns ic on ic.index_id = i.index_id and ic.object_id = i.object_id
join sys.columns c on c.object_id = o.object_id and c.column_id = ic.column_id
join sys.types t on c.system_type_id = t.system_type_id

Issue with auto update stats

$
0
0

Hi All,

I have a database upon which the auto create and update stats is ON which I found by following query,

   
   SELECT NAME    	,is_auto_create_stats_on    	,is_auto_update_stats_on    FROM sys.databases


I obsereved that stats are not being updated automatically for all indexes. I found that using the below query,

 
  SELECT name AS index_name,    STATS_DATE(OBJECT_ID, index_id) AS StatsUpdated    FROM sys.indexes    ORDER BY STATS_DATE(OBJECT_ID, index_id) DESC



Does anyone faced the same issue and whats the resolution for the issue

Microsoft best practice for ssd

$
0
0

Hi,

i can't find any new article from microsoft about using SQL server 2012/2014 on SSD drive.

what is the best practice about putting DATA file,LOG file and TEMPDB files on SSD RAID's perspective and what types of SSD?

THX

SQL Server NON-DEFAULT Tracing stops all of a sudden

$
0
0

Dear all,

we have enabled the SQL tracing on SQL servers but for some databases the tracing is disabled without any reason and then we have to enable it manually. This is happening on frequent basis.


here is what we have done.
1.Procedure CREATE PROC [dbo].[AuditTrcProc] with Tracing events
2.EXEC AuditTrcProc
3.EXEC sp_procoption 'AuditTrcProc', 'startup', 'TRUE';


 the tracing is generated to Shared location say NFS_Share_name\ServerName\sessiontrace.trc [ this is with sequence number and when it gets 1 MB is size another file is created]


 All works perfect, but  this tracing is disabled on many servers randomly.

output of the query is null for non-default tracing  [ no issues with default tracing]


 SELECT * FROM :: fn_trace_getinfo(default)


Appreciate your feedback on this issue

Regards,

Aijaz


Cannot enlist in the transaction because the transaction does not exist

$
0
0

Hello,

I'm running SQL Server 2012 Standard Edition (11.0.5532.0) on the top of a Windows Server 2012R2, the instance is dedicated to host Sharepoint.

Since some hours I see the following error in the ERRORLOG:

Date31/05/2016 09:49:24 AM
LogSQL Server (Current - 31/05/2016 09:49:00 AM)

Sourcespid22s

Message
Cannot enlist in the transaction because the transaction does not exist.

Any idea?

Utility Control Point doesn't provide instances info

$
0
0

Dear all,

I am just set up Utility Control Point server (using my local box 2014) and then I included some PROD servers around but in fact, after a while, I don’t get info from Utility Explorer Content. I see all the servers enrolled with CPU, Volume Space, File Space, Operating System Version and so on but everything is in gray, without values (collect data is 0)

What else need I activate in order to see data up and down?

Thanks for any input or hint related to,

resource governor 2014 restrict user

$
0
0

Hi

Does any one know if it is possible to use resource governor 2014 to restrict resources used by a user query?

SQL Server 2014 TLS 1.2 and Database Email Unsent status

$
0
0

Version Installed:

Microsoft SQL Server 2014 (SP1-CU6) (KB3144524) - 12.0.4449.0 (X64)
 Apr 13 2016 12:41:07
 Copyright (c) Microsoft Corporation
 Developer Edition (64-bit) on Windows NT 6.3 <X64> (Build 9600: ) (Hypervisor)

TLS 1.2 has been enabled at Windows OS 2012 R2 standard edition and TLS 1.0 has been disabled.

Database Mail works fine when TLS 1.0 is enabled; however, it doesn't when it is disabled. msdb.dbo.sp_send_dbmail doesn't report any error; however, messages remains in 'unsent' status in msdb.dbo.sysmail_unsentitems.

All necessary patches already applied as per KB https://support.microsoft.com/en-us/kb/3135244

AdO.NET updated and .NET framework latest version installed. Other than database mail there is no issue with any other service/tool.

Application log shows the following error:

1) Exception Information
===================
Exception Type: Microsoft.SqlServer.Management.SqlIMail.Server.Common.BaseException
Message: There was an error on the connection. Reason: A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.), connection parameters: Server Name: TEST-SQL03, Database Name: msdb
Data: System.Collections.ListDictionaryInternal
TargetSite: Void OpenConnection(Microsoft.SqlServer.Management.Common.SqlConnectionInfo)
HelpLink: NULL
Source: DatabaseMailEngine

StackTrace Information
===================
   at Microsoft.SqlServer.Management.SqlIMail.Server.DataAccess.ConnectionManager.OpenConnection(SqlConnectionInfo connectionInfo)
   at Microsoft.SqlServer.Management.SqlIMail.Server.DataAccess.DataAccessAdapter.OpenConnection(String dbServerName, String dbName, String userName, String password, String appName, Int32 connectionTimeout)
   at Microsoft.SqlServer.Management.SqlIMail.Server.DataAccess.DataAccessAdapter.OpenConnection(String dbServerName, String dbName, String userName, String password, Int32 connectionTimeout)
   at Microsoft.SqlServer.Management.SqlIMail.IMailProcess.QueueItemProcesser.ProcessQueueItems(String dbName, String dbServerName, Int32 lifetimeMinimumSec, LogLevel loggingLevel, Byte[] encryptionKey, Int32 connectionTimeout)

2) Exception Information
===================
Exception Type: System.Data.SqlClient.SqlException
Errors: System.Data.SqlClient.SqlErrorCollection
Class: 20
LineNumber: 0
Number: 233
Procedure: NULL
Server: TEST-SQL03
State: 0
Source: .Net SqlClient Data Provider
ErrorCode: -2146232060
Message: A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)
Data: System.Collections.ListDictionaryInternal
TargetSite: System.Data.ProviderBase.DbConnectionInternal GetConnection(System.Data.Common.DbConnection)
HelpLink: NULL

StackTrace Information
===================
   at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.SqlClient.SqlConnection.Open()
   at Microsoft.SqlServer.Management.SqlIMail.Server.DataAccess.ConnectionManager.OpenConnection(SqlConnectionInfo connectionInfo)

 

How to track all the Integration Services running around my network?

$
0
0

Dear all, using this cmdlet you can search for all the servers and its instances running (on the condition SqlBrowser service is up)

[System.Data.Sql.SqlDataSourceEnumerator]::Instance.GetDataSources()

How can we achieve the same with Integration Services? I've got IS in my local box but I'd like to know who else in other floors own similar schema

Thanks in advance for any input,


Viewing all 15872 articles
Browse latest View live


Latest Images

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