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

The target principal name is incorrect. Cannot generate SSPI context.

$
0
0

Server, Windows 10 HOME 32 Bit, MS SQL Server 2014

Client, Windows 10 HOME 64 Bit

Everything was working fine, now all of a sudden I'm getting the above when I try and access the server from Visual Studio.

Almost everything I can find about it is DC/Active directory related.  I'm on Windows home, so no DC.

The only error I see in the event viewer is:

Error Schannel36882 None

That event is because of the self signed cert and is supposed to be ignorable. 

I tried switching to "SQL Server Authentication"

But now I get:

A connection was successfully established to the server, but then an error occurred during the pre-login handshake. 

I think an SQL update was part of the Visual Studio updates I installed yesterday and may be part of the problem.

Edit: After a reboot on the client I was able to "SQL Server Authentication" running. (Note: if you do this you will also need to enable SQL Server Authentication on the server and create a log in account.)

Still curious why I get the "Cannot generate SSPI context." all of a sudden.


John Fenton, MCC2011
Senior Programer Data Automation Systems





Error on occurred when a procedure run

$
0
0

Facing a prob. when a procedure executing : "Logical consistence based Error ....."

ssms scripting error

$
0
0

i am using ssms 2016 vs a 2008 database. i get a scripting error message when attempting to modify or script an SP

when I use ssms 2014 it works with no problems. i have tried dropping and recreating the sp using 2016 and it still does not work

the message:

TITLE: Microsoft SQL Server Management Studio
------------------------------

Script failed for StoredProcedure 'dbo.rashim_adv_search'.  (Microsoft.SqlServer.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=13.0.15800.18+((SSMS_Rel).160914-0312)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Script+StoredProcedure&LinkId=20476

------------------------------
ADDITIONAL INFORMATION:

Syntax error in TextHeader of StoredProcedure 'rashim_adv_search'. (Microsoft.SqlServer.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=13.0.15800.18+((SSMS_Rel).160914-0312)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&LinkId=20476

------------------------------
BUTTONS:

OK
------------------------------

it seems to affect all SPs



???


SMO causing deadlock

$
0
0

We have .Net code that does database replication using SMO. We use SMO to extract schema from source database and create them in destination database. And in recent past we started receiving bunch of deadlock issues. On analyzing the deadlocks graphs we found that some system base tables (ex: sys.sysrowsets) are causing the deadlocks. On some more investigation we found that..there are some SQL jobs running on parent DB that alter few tables (like renaming column, creating new column, dropping and recreating index etc.) that will internally update SQL Server base tables. At the same time using SMO we are capturing definition of tables which again depends upon system base tables internally. This is causing deadlock and SMO is the deadlock victim.

My question is

1. Is there is any setting available for SMO that will avoid deadlocks?

2. If not is there is any simple alternate way to extract schema of SQL objects?

For you reference I am pasting the error and deadlock graph here:

<StackTrace>   at Microsoft.SqlServer.Management.Smo.Scripter.ScriptWithList(DependencyCollection depList, SqlSmoObject[] objects, Boolean discoveryRequired)

   at Microsoft.SqlServer.Management.Smo.Scripter.ScriptWithList(Urn[] urns, SqlSmoObject[] objects)

   at Microsoft.SqlServer.Management.Smo.Scripter.Script(Urn[] urns, SqlSmoObject[] objects)

   at DataMigration.BulkCopyTable(String schemaName, String tableName)  at DataMigration.CopyTableWithData()

</StackTrace>

<ExceptionSource>Microsoft.SqlServer.Smo</ExceptionSource><Data><HelpLink.ProdName>Microsoft SQL Server</HelpLink.ProdName><HelpLink.BaseHelpUrl>http://go.microsoft.com/fwlink</HelpLink.BaseHelpUrl><HelpLink.LinkId>20476</HelpLink.LinkId><HelpLink.ProdVer>11.0.2100.60 ((SQL11_RTM).120210-1917 )</HelpLink.ProdVer><HelpLink.EvtSrc>Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText</HelpLink.EvtSrc><HelpLink.EvtData1>Script</HelpLink.EvtData1><HelpLink.EvtData2>Server</HelpLink.EvtData2></Data><SqlException><Message>Transaction (Process ID 379) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.</Message>

 

 

 

SQLServer 2016 - "Maintenance clean up task" stuck - xp_delete_file problem

$
0
0

Hello,

On our new SQLServer 2016, the "Maintenance Cleanup Task" do not delete backup file.

I never had the problem with on older installation (2008R2 to 2014)

In the activity monitor, the session running this command is waiting on "MSQL_XP" .

 "EXECUTE master.dbo.xp_delete_file 0,N'U:\Backup\MSSQL13.SSDE\MSSQL\Backup\model\model_backup_2016_09_16_155708_9880904.bak'"

Then after 60 seconds, the task go in error : 

Executed as user: xxxx\yyyyy . Microsoft (R) SQL Server Execute Package Utility  Version 13.0.1601.5 for 64-bit  Copyright (C) 2016 Microsoft. All rights reserved.    Started:  16:08:16  Progress: 2016-09-16 16:08:16.77    Source: {F609BD64-CBC9-42CF-85EE-3537D0A1DF7A}      Executing query "DECLARE @Guid UNIQUEIDENTIFIER      EXECUTE msdb..sp...".: 100% complete  End Progress  Error: 2016-09-16 16:09:16.89     Code: 0xC002F210     Source: Maintenance Cleanup Task Execute SQL Task     Description: Executing the query "EXECUTE master.dbo.xp_delete_file 0,N'U:\Backup\MS..." failed with the following error: "Error executing xp_delete_file extended stored procedure: Specified file is not a SQL Server backup file.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.  End Error  DTExec: The package execution returned DTSER_FAILURE (1).  Started:  16:08:16  Finished: 16:09:17  Elapsed:  60.938 seconds.  The package execution failed.  The step failed.

I tried reading the header of this file, no problem found :

RESTORE HEADERONLY 
FROM DISK = N'U:\Backup\MSSQL13.SSDE\MSSQL\Backup\model\model_backup_2016_09_16_155708_9880904.bak' 
WITH NOUNLOAD;
GO

model_backup_2016_09_16_155708_9880904NULL1NULL012saSERVER\SSDEmodel8522003-04-08 09:13:36.0002833408340000001727000373400000017440000134000000172700037340000001665000372016-09-16 15:57:09.0002016-09-16 15:57:09.00000103319660913046081301708SERVER 512EBD0FE66-F91F-43F1-99C3-B52D803BB13690D16058-F1D1-4E96-8EC6-8D7BFDA42F15Latin1_General_CI_ASEBD0FE66-F91F-43F1-99C3-B52D803BB136000000000090D16058-F1D1-4E96-8EC6-8D7BFDA42F15NULLSIMPLENULLNULLDatabaseBC2B2591-4ECC-4760-8811-5E5D3EECCABD28334080NULLNULLNULL

I tried to delete a specific Maintenance plan text report, it worked fine. This problem seems to be specific for backup file, compressed or not.

I have the same problem on  every other server with SQLServer 2016.


SQL Server 2014 columnstore with partitioning/indexed views bug

$
0
0

Hi all,

This appears to be two separate bugs in SQL Server 2014, but somewhat related.  I'm running the latest cumulative update (version 12.0.2342).

Basically, I have a simple table that I partition and create a clustered columnstore index on.  Then, I create an indexed view with some of the columns.  The actual creation of the index fails with:

"Internal Query Processor Error: The query processor could not obtain access to a required interface."

If I reverse the order (i.e. create the indexed view on the table first, then create the columnstore index), it works fine.

Secondly, with or without partitions, if I create a clustered columnstore indexed table, then create an indexed view that contains an NVARCHAR column in the view, bulk inserts will fail with:

"SQL Server Assertion: File: <valrow.cpp>, line=415 Failed Assertion = '*((ULONG*)(pb + x_ibLengthInBuffer)) <= m_cbMaxLen'. This error may be timing-related. If the error persists after rerunning the statement, use DBCC CHECKDB to check the database for structural integrity, or restart the server to ensure in-memory data structures are not corrupted."

Of course, I have done a DBCC CHECKDB to no success.

The script to reproduce the former is below.  To test the bulk insert, simply create the structure without the partitioning and then use an SSIS package or what not to try to bulk load some data.

SET NOCOUNT ON

CREATE PARTITION FUNCTION [SalesByDate](datetime2(7)) AS RANGE LEFT FOR VALUES (N'1970-01-01T00:00:00.000', N'2013-01-01T00:00:00.000', N'2014-01-01T00:00:00.000')
CREATE PARTITION SCHEME [SalesByDate] AS PARTITION [SalesByDate] TO ([PRIMARY], [PRIMARY], [PRIMARY], [PRIMARY])

CREATE TABLE [dbo].[Test](
	[TestId] [bigint] NOT NULL IDENTITY(1,1),
	[Key] nvarchar(50) NOT NULL,
	[Date] [datetime2](7) NOT NULL,
	[Num] [int] NOT NULL
) ON SalesByDate (Date)
GO

DECLARE @i INT = 0

WHILE @i < 100000
BEGIN
INSERT INTO dbo.Test
SELECT 'Blah!', DATEADD(DAY, CAST(RAND() * 720 as INT), '2013-01-01'), CAST(RAND() * 100 as INT)
UNION ALL
SELECT 'Blah!', DATEADD(DAY, CAST(RAND() * 720 as INT), '2013-01-01'), CAST(RAND() * 100 as INT)
UNION ALL
SELECT 'Blah!', DATEADD(DAY, CAST(RAND() * 720 as INT), '2013-01-01'), CAST(RAND() * 100 as INT)
UNION ALL
SELECT 'Blah!', DATEADD(DAY, CAST(RAND() * 720 as INT), '2013-01-01'), CAST(RAND() * 100 as INT)
UNION ALL
SELECT 'Blah!', DATEADD(DAY, CAST(RAND() * 720 as INT), '2013-01-01'), CAST(RAND() * 100 as INT)
UNION ALL
SELECT 'Blah!', DATEADD(DAY, CAST(RAND() * 720 as INT), '2013-01-01'), CAST(RAND() * 100 as INT)
UNION ALL
SELECT 'Blah!', DATEADD(DAY, CAST(RAND() * 720 as INT), '2013-01-01'), CAST(RAND() * 100 as INT)
UNION ALL
SELECT 'Blah!', DATEADD(DAY, CAST(RAND() * 720 as INT), '2013-01-01'), CAST(RAND() * 100 as INT)
UNION ALL
SELECT 'Blah!', DATEADD(DAY, CAST(RAND() * 720 as INT), '2013-01-01'), CAST(RAND() * 100 as INT)
UNION ALL
SELECT 'Blah!', DATEADD(DAY, CAST(RAND() * 720 as INT), '2013-01-01'), CAST(RAND() * 100 as INT)

SET @i = @i + 10
END

GO

CREATE CLUSTERED COLUMNSTORE INDEX PK_Test ON dbo.Test ON SalesByDate (Date)
GO

CREATE VIEW [dbo].[TestView]  WITH SCHEMABINDING
AS

SELECT [Date],
	[Key],
	[TestId]
  FROM [dbo].[Test]
GO

CREATE UNIQUE CLUSTERED INDEX PK_TestView ON dbo.TestView (Date, TestId) ON SalesByDate (Date)
GO

Setting processor/IO affinity mask using sp_configure

$
0
0

Hi,

In SSMS, sql server 2014 shows 4 NumaNodes (0-3), each of them 20 CPUs. I know that this server has 4 physical cores, with 10 logical CPUs (schedulers) each. First of all, why is SSMS showing 80 CPUs, when I know that we have only 40 logical cores???

Also, we plan to set Processor/Affinity mask to use only half of CPUs (don't ask why, it is part of the test), so considering what I said about incorrect number of CPUs shown in SSMS, and fact that we have 40 Cores, what would be sp_configure 'affinity mask' value for this server to use only 24 cores (out of 40)???? I found only simple examples online (including Microsoft and BOL), where they show only i.e. 8 CPUs (i.e. 11111110 meaning 254).

This command returns 40:

select scheduler_id,cpu_id, status, is_online from sys.dm_os_schedulers where status='VISIBLE ONLINE'

...and this returns 80, 20, and 4 respectively:

select cpu_count, hyperthread_ratio, cpu_count/hyperthread_ratio as physical_cpu_count from sys.dm_os_sys_info

Thanks,



Pedja

Occasional connectivity issues.

$
0
0

Greetings. We are getting SQL Server connectivity errors on a very intermittent basis. We've looked everywhere and all the info we have is posted below from the various sources. Note that this is not occurring from just one app server but a few, and that it's also occurring on more than one SQL Server instance.

Application Error (more details lower in the thread):

The connection error occurred again last night (log message):

System.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake.

SQL Message Captured:

-         Interesting to note the high time to establish SSL in yellow

-         <value>Network error code 0x2746 occurred while establishing a connection; the connection has been closed. This may have been caused by client or server login timeout expiration.Time spent during login: total 12109 ms, enqueued 0 ms, network writes 1 ms, network reads 2109 ms,establishing SSL 9997 ms, network reads during SSL 9997 ms, network writes during SSL 0 ms, secure calls during SSL 0 ms, enqueued during SSL 0 ms, negotiating SSPI 0 ms, network reads during SSPI 0 ms, network writes during SSPI 0 ms, secure calls during SSPI 0 ms, enqueued during SSPI 0 ms, validating login 0 ms, including user-defined login processing 0 ms. [CLIENT: myIPAddress]</value>

Network Capture (trace file attached):

-         There are several retransmissions from the SQL instance to the App server (myAppServer (myIPAddress)

-         Then there is a reset request from the app server to the SQL instance

-         467         2016-07-19 08:27:00.405430160  10.7.50.10            10.7.4.125            TCP        68           44590 1433 [RST, ACK] Seq=1496031372 Ack=1496031636 Win=0 Len=0

-         Also see the below regarding SSL Self Signed Fallback.

...^......$....*....+....,....0....1.$..U......:............v,..M...K.?.....j...B..w.}./{........0...........%....&....'....'....(............[1496030773 bytes missing in capture file]...^......$....*....+....,....0....1.$..U......:............v,..M...K.?.....j...B..w.}./{.....[1496030819 bytes missing in capture file]...0...........%....&....'....'....(...............................W.......y`...3.....@..!.F...B0....*.<./.=.5...

.'.....+.#.,.$. .

.@.2.j.8.......G........

myDBServer.

...............

..................................m........`...Q..W......`.....N&. .~ot.U.zr3 .... B0....j.zO.'Q\..5..X..@q....gP...<.. ...................0...0..b...........T...Iu....0.0

. *.H..

.....0;1907..U...0.S.S.L._.S.e.l.f._.S.i.g.n.e.d._.F.a.l.l.b.a.c.k0..

160714073545Z.

460714073545Z0;1907..U...0.S.S.L._.S.e.l.f._.S.i.g.n.e.d._.F.a.l.l.b.a.c.k0..0

. *.H..

.........0.......R..H...4.....Jr.U.4rl'..?.N

.- .._k...-... q...j...[(.2'...Nc.4......WbTI..W..j.;..(+S/..U..P%..&..;.....#..Y....E....o{a.6..h5.....0

. *.H..

............/....;.u..8...... F].X..xP-.^\.H.[......@...G...lG:*......wJ...Eh......$....;.........s......f.,.n......PP#.G......->7.:............................1.XL..&....P...JM.....]D....v?N....`E{N..._?.9.OG....w..Ph.......!....5..e.m......Po.....G.../s...X..[..!]...g....*.8..K..+Y=.............P.w......"...........j...p.....,....U.. mol.D].w')..!..N.)........J2F.!.4.....C.....c..............Pf..|..

p..PC.f.7....

....~sGT...4f./.L..j...dp.....T.>............(....p......U.

All ideas are welcome, thanks!


Thanks in advance! ChrisRDBA



how to solve [Microsoft][SQL Server Native Client 11.0]SMux Provider: Physical connection is not usable [xFFFFFFFF].

$
0
0

Windows server 2012R2.

SQL Server 2012R2.

client windows 10. 

Error:  [Microsoft][SQL Server Native Client 11.0]SMux Provider: Physical connection is not usable [xFFFFFFFF].   Please refer this error to your database administrator or see your database documentation for further assistance.

Spread one table across multiple data files

$
0
0

Hello

Is there a way to spread the data of one table across multiple data files? As far as I know we cannot really achieve it unless we have table partitioning and place the indexes on multiple filegroups/files.

Please confirm this and let me know if there is a way to spread the data of one non-partitioned table across multiple data files.

- Satya

Using certificate and private key to encrypt and decrypt sensitive data

$
0
0

Hi all,

I need to be able to encrypt and decrypt data as secure as possible, but considering also the following requirements:

- Be able to export keys/certificates in order to install them in other servers (I'm not sure if this makes sense);

- Hide details such as the private key password

This is a topic where I'm not so confortable with, I'm not sure where should I begin and how certificates and private keys relate in sql server, where to create them (I have nothing), how to relate certificate and private key, how to encrypt, how to decrypt.

So far I did this and I believe is not correct (at least decrypt returns NULL):

CREATE CERTIFICATE
  MyCertificate
  ENCRYPTION BY PASSWORD = 'MyPassword.123'
  WITH SUBJECT='My precious certificate'

CREATE SYMMETRIC KEY MyKey
WITH ALGORITHM = AES_256
ENCRYPTION BY CERTIFICATE MyCertificate

DECLARE @cipherText VARBINARY(128) = ENCRYPTBYCERT(CERT_ID('MyCertificate'), 'ABCDEFG')
DECLARE @clearText VARCHAR(128) = DECRYPTBYCERT(CERT_ID('MyCertificate'), @cipherText)
SELECT @cipherText, @clearText

I'm sorry if my topic seems not too specific, but I'm not sure what am I doing wrong here and what should I be exactly doing.

DBCC SHRINKFILE in SQL Server 2008 R2

$
0
0

Hi,

What is meaning of below commanrd in in SQL Server 2008 R2 ?

DBCC SHRINKFILE (N'ReportServer' , 500)


Regards, Bijay Maurya

No . of Logins in SQL Server Database

$
0
0

Hi All,

I want to know how many users logged in to or accessed  my database in a given time frame.

I know that I can get the active users using sysprocesses but I have a requirement in which client is asking for the number of users using the database in a given time.

Any help will be appreciated.

Some SQL jobs suddenly stop working, always "executing"

$
0
0
Hello, we have a had a few SQL jobs start executing but not finishing. Sometimes they fail after 30-40 hours, but usually we catch them and cancel them. The jobs are stored procedures that run in just a couple seconds if we just execute the SP. The jobs ran fine until a week or so ago, I don't know of any changes to the server. I do know if I run the job scheduled or manually start the job, it is always failing. If I just run the SP, it is always succeeding. Nothing appears in the error logs. The jobs say they are executing, but they never finish. I tried to force recompile on the SPs in case there was a parameter sniffing issue, but that didn't help. 

when does sql optimizer uses stream aggregate or hash aggregate

$
0
0

Hi,
Just want to know when does sql optimizer uses stream aggregate or hash aggregate, as per my understanding cardinality estimation play a vital role in choosing this, so when i test using 2014 CE it  chooses stream aggregate (memory highly used because of sort before stream) if i check in 2012 CE is uses hash aggregate, which is more efficient comparable to former.
even the choice doing index seek and scan is also different as different CE which is understandable..
but the choice of stream aggregate or hash aggregate is different in another server with same environment.
so just want to know how sql server chooses stream aggregate or hash aggregate based on what?

thanks


Best Regards Moug


SQLServer Crashes over simple SQL

$
0
0

SQLServer 2008, the following SQL will cause the session to crash (literally disconnect you):

select coalesce(convert(nvarchar, (SELECT MAX(v) FROM (VALUES (1, 2)) AS T(v))), '');

Just want the related parties to know and log the bug with development accordingly.

dynamic sql - sp_prepexec and DMV

$
0
0

I have to get a list of CPU intensive queries for a database whose queries for the most part come from a middle -tier (GuideWire).

In SQLProfiler, I see lot of requests coming in but all of them are dynamic sql (sp_prepexec, sp_unprepare) statements. 

When I run the below query to get a list of queries I don't see anything at all. Am I missing something? Should I be looking else where?

SELECT TOP(10)
creation_time
, last_execution_time
, (total_worker_time+0.0)/1000 AS total_worker_time
, (total_worker_time+0.0)/(execution_count*1000) AS [AvgCPUTime] , 

execution_count

FROM sys.dm_exec_query_stats qs

CROSS APPLY sys.dm_exec_sql_text(sql_handle) st
WHERE st.dbid = 53
ORDER BY total_worker_time DESC


Failed to initialize sqlcmd library with error number -2147467259.

$
0
0

When i try to execute through SSMS it fails.If i remove @query parameter,it works fine.

I also tested the query which is good.

EXEC msdb.dbo.sp_send_dbmail @profile_name = 'sqlmail',
    @recipients = 'kvenkata@gmail.com;',
    @query='select * from DB_Name.dbo.config',
@body = 'Data in Database is changed', @subject = 'Record has been Updated/Deleted/Inserted';

Error: Failed to initialize sqlcmd library with error number -2147467259.

If i run this script in a sql job,it runs fine even if i include @query parameter.



SQL Server 2016 log file not shrinking

$
0
0

I have an SQL Server 2016 database set to full recovery mode which is ~400Mb however the log is almost 30Gb. Whether I perform a full backup in SSMS or using tsql or manually try to shrink it, it wont lower in size. It shows 99% available free space when attempting to shrink.

There are no open transactions reported by DBCC OPENTRAN, however the application that accesses the database has a Window service which when stopped allows the log file to be flushed.

What can I report through SQL Server that may indicate what the developer has done causes this?

Thanks.

what happens in the background when update statement fires in the SQL Server?

$
0
0

Hello All,

What happens in the background when update statements gets executed. will that statement locks row/page/table till the execution completes? if it locks, what could be the locks are?. Please suggest me on how the execution would be done in the background/



Thanks & Regards, Anil

Viewing all 6624 articles
Browse latest View live