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

questing on bcp

$
0
0

1. How to export data with an input sql file ?

currently use

bcp "select …… from …." queryout "output.csv" -c -T -t "?" -S server

can do

bcp -i "file.sql" queryout "output.csv" -c -T -t "?" -S server where file.sql is the query ? Because my query is very long.

2. How to export the header together ?


SQL statistics IO

$
0
0

I have the following output from statistics IO

(30 rows affected)
Table 'testing_pic3'. Scan count 1, logical reads 1, physical reads 0, read-ahead reads 0, lob logical reads 275108, lob physical reads 0,lob read-ahead reads 459336.

yes. the table has image column.

so how many read ( in MB ) for this query ?

What is meant by %d in the sql server code...

$
0
0

Hi Experts,

In the piece of already written code by some one in my project, i saw the %d  as shown in the below context.

Declare @count INT
  SELECT @count = COUNT(1) FROM dbo.test 
  RAISERROR('COUNT %d', 0, 1, @count) WITH NOWAIT

here dbo.test is the user defined table that holds some records.

have any body has idea about %d in the above code.

Thanks in Advance.

Why does SQL Server 2012 allow duplicate primay keys?

$
0
0

I have a table with a uniqueidentifier as primary key (IGNORE_DUP_KEY set to off) and an index of that key set to Unique, Non-Clustered. But still I am allowed to insert duplicate rows into my table. (It took me some time to discover that this was the reason that a service I run against that database suddenly started to mysteriously stop working at more or less regular intervals).

If I delete the primary key and then try to recreated it I will get an error telling me that it cant be created due to duplicate rows but if I remove these duplicate rows and then recreate the primary key I am once again free to add the duplicate rows to the table without problem.

My database used to run on an SQL Server 2008 machine and back then I didn’t have this problem. Now I run my database on SQL Server 2012 Enterprise Edition (64-bit) v11.0.7001.0

Can't bring the SQL Server resource online On Cluster Node when fail over .

$
0
0

I can't bring the SQL Server resource online on the  Node 2 its working fine on Node 1.

I can see the below error in Event Log.

The description for Event ID 19019 from source MSSQLSERVER cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.


If the event originated on another computer, the display information had to be saved with the event.

The following information was included with the event: 

[sqsrvres] OnlineThread: Error 2 bringing resource online.

SQL Error :- 

 -d E:\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\master.mdf
-e E:\MSSQL10_50.MSSQLSERVER\MSSQL\Log\ERRORLOG
-l E:\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\mastlog.ldf
2019-02-23 11:19:08.88 Server      SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2019-02-23 11:19:08.88 Server      Detected 16 CPUs. This is an informational message; no user action is required.
2019-02-23 11:19:08.88 Server      Large Page Extensions enabled.
2019-02-23 11:19:08.88 Server      Large Page Granularity: 2097152 
2019-02-23 11:19:08.93 Server      Cannot use Large Page Extensions: Failed to allocate 32MB
2019-02-23 11:19:08.93 Server      Cannot use Large Page Extensions: Failed to allocate 32MB
2019-02-23 11:19:08.94 Server      Cannot use Large Page Extensions: Failed to allocate 32MB
2019-02-23 11:19:09.06 Server      Using locked pages for buffer pool.
2019-02-23 11:19:09.27 Server      Using dynamic lock allocation.  Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node.  This is an informational message only.  No user action is required.
2019-02-23 11:19:09.27 Server      Lock partitioning is enabled.  This is an informational message only. No user action is required.
2019-02-23 11:19:09.30 Server      Node configuration: node 0: CPU mask: 0x000000000000ff00:0 Active CPU mask: 0x000000000000ff00:0. This message provides a description of the NUMA configuration for this computer. This is an informational message only. No user action is required.
2019-02-23 11:19:09.30 Server      Node configuration: node 1: CPU mask: 0x00000000000000ff:0 Active CPU mask: 0x00000000000000ff:0. This message provides a description of the NUMA configuration for this computer. This is an informational message only. No user action is required.
2019-02-23 11:19:09.35 spid9s      Starting up database 'master'.
2019-02-23 11:19:09.43 spid9s      Recovery is writing a checkpoint in database 'master' (1). This is an informational message only. No user action is required.
2019-02-23 11:19:09.50 spid9s      CHECKDB for database 'master' finished without errors on 2018-01-30 00:04:22.590 (local time). This is an informational message only; no user action is required.
2019-02-23 11:19:09.53 spid9s      Resource governor reconfiguration succeeded.
2019-02-23 11:19:09.53 spid9s      SQL Server Audit is starting the audits. This is an informational message. No user action is required.
2019-02-23 11:19:09.53 spid9s      SQL Server Audit has started the audits. This is an informational message. No user action is required.
2019-02-23 11:19:09.53 spid9s      FILESTREAM: effective level = 0, configured level = 0, file system access share name = 'MSSQLSERVER'.
2019-02-23 11:19:09.56 spid9s      SQL Trace ID 1 was started by login "sa".
2019-02-23 11:19:09.57 spid9s      Starting up database 'mssqlsystemresource'.
2019-02-23 11:19:09.58 spid9s      The resource database build version is 10.50.6000. This is an informational message only. No user action is required.
2019-02-23 11:19:09.88 spid9s      Server name is '1V01'. This is an informational message only. No user action is required.
2019-02-23 11:19:09.88 spid9s      The NETBIOS name of the local node that is running the server is 'NodeA'. This is an informational message only. No user action is required.
2019-02-23 11:19:09.88 spid12s     Starting up database 'model'.
2019-02-23 11:19:10.05 Server      A self-generated certificate was successfully loaded for encryption.
2019-02-23 11:19:10.09 spid12s     CHECKDB for database 'model' finished without errors on 2016-06-17 02:01:06.790 (local time). This is an informational message only; no user action is required.
2019-02-23 11:19:10.10 spid12s     Clearing tempdb database.
2019-02-23 11:19:10.17 Server      Server is listening on [ 10.10.10.1 <ipv4> 1433].
2019-02-23 11:19:10.17 Server      Server local connection provider is ready to accept connection on [ \\.\pipe\SQLLocal\MSSQLSERVER ].
2019-02-23 11:19:10.17 Server      Server named pipe provider is ready to accept connection on [ \\.\pipe\$$\V01\sql\query ].
2019-02-23 11:19:10.27 spid12s     Starting up database 'tempdb'.
2019-02-23 11:19:10.33 spid15s     A new instance of the full-text filter daemon host process has been successfully started.
2019-02-23 11:19:10.35 spid16s     The Service Broker protocol transport is disabled or not configured.
2019-02-23 11:19:10.35 spid16s     The Database Mirroring protocol transport is disabled or not configured.
2019-02-23 11:19:10.35 spid16s     Service Broker manager has started.

2019-02-23 11:19:12.32 Server      The SQL Server Network Interface library could not register the Service Principal Name (SPN) for the SQL Server service. Error: 0x202b, state: 15. Failure to register an SPN may cause integrated authentication to fall back to NTLM instead of Kerberos. This is an informational message. Further action is only required if Kerberos authentication is required by authentication policies.
2019-02-23 11:19:12.32 Server      SQL Server is now ready for client connections. This is an informational message; no user action is required.
2019-02-23 11:19:23.84 spid52      Configuration option 'show advanced options' changed from 0 to 1. Run the RECONFIGURE statement to install.
2019-02-23 11:19:23.84 spid52      FILESTREAM: effective level = 0, configured level = 0, file system access share name = 'MSSQLSERVER'.
2019-02-23 11:19:23.84 spid52      Configuration option 'Agent XPs' changed from 0 to 1. Run the RECONFIGURE statement to install.
2019-02-23 11:19:23.84 spid52      FILESTREAM: effective level = 0, configured level = 0, file system access share name = 'MSSQLSERVER'.
2019-02-23 11:19:23.85 spid52      Configuration option 'show advanced options' changed from 1 to 0. Run the RECONFIGURE statement to install.
2019-02-23 11:19:23.85 spid52      FILESTREAM: effective level = 0, configured level = 0, file system access share name = 'MSSQLSERVER'.
2019-02-23 11:19:24.15 spid52      Attempting to load library 'xpsqlbot.dll' into memory. This is an informational message only. No user action is required.
2019-02-23 11:19:24.16 spid52      Using 'xpsqlbot.dll' version '2009.100.1600' to execute extended stored procedure 'xp_qv'. This is an informational message only; no user action is required.
2019-02-23 11:19:24.27 spid52      Attempting to load library 'xpstar.dll' into memory. This is an informational message only. No user action is required.
2019-02-23 11:19:24.28 spid52      Using 'xpstar.dll' version '2009.100.1600' to execute extended stored procedure 'xp_instance_regread'. This is an informational message only; no user action is required.
2019-02-23 11:19:24.32 spid52      Attempting to load library 'xplog70.dll' into memory. This is an informational message only. No user action is required.
2019-02-23 11:19:24.33 spid52      Using 'xplog70.dll' version '2009.100.6000' to execute extended stored procedure 'xp_msver'. This is an informational message only; no user action is required.
2019-02-23 11:27:24.29 spid53      Configuration option 'show advanced options' changed from 0 to 1. Run the RECONFIGURE statement to install.
2019-02-23 11:27:24.29 spid53      FILESTREAM: effective level = 0, configured level = 0, file system access share name = 'MSSQLSERVER'.
2019-02-23 11:27:24.29 spid53      Configuration option 'Agent XPs' changed from 1 to 0. Run the RECONFIGURE statement to install.
2019-02-23 11:27:24.29 spid53      FILESTREAM: effective level = 0, configured level = 0, file system access share name = 'MSSQLSERVER'.
2019-02-23 11:27:24.30 spid53      Configuration option 'show advanced options' changed from 1 to 0. Run the RECONFIGURE statement to install.
2019-02-23 11:27:24.30 spid53      FILESTREAM: effective level = 0, configured level = 0, file system access share name = 'MSSQLSERVER'.
2019-02-23 11:27:26.29 spid16s     Service Broker manager has shut down.
2019-02-23 11:27:26.39 spid9s      SQL Server is terminating in response to a 'stop' request from Service Control Manager. This is an informational message only. No user action is required.
2019-02-23 11:27:26.39 spid9s      SQL Trace was stopped due to server shutdown. Trace ID = '1'. This is an informational message only; no user action is required.

Could you Please help me on this issue.




CPU Performance

$
0
0

We've inherited some SQL server 2014 databases, they are running on Azure IaaS.  We're getting complaints about performance and trying to get a grip on it.  We're starting to look at CPU performance, and run the following test:

DECLARE @Loops INT SET @Loops = 1
DECLARE @CPU INT SET @CPU = @@CPU_BUSY
DECLARE @StartDate DATETIME SET @StartDate = GETDATE()

WHILE @Loops <= 100000
BEGIN
    IF COALESCE('123', '456') = '456'  
            PRINT 1
    SET @Loops = @Loops + 1   
END

On Production machine, 16 Virtual Processors (20 to 30% busy), we get the following result:

Total CPU time: 1150
Total milliseconds: 13473

On test machine, 4 Virtual Processors (also around 20 to 30% busy) we get the following:
Total CPU time: 2
Total milliseconds: 1183

I've tried running a few benchmarks on the production machine, but they don't show any problems, and always show the production machine CPU at least twice as powerful as test machine.

Is there some SQL Server setting that might be configured wrongly?  Any idea how to troubleshoot this issue?

dbcc sqlperf(logspace) percentage

$
0
0

I have a sample database testing , using sqlperf(logspace) and see the percentage use is around 3% , Logsize around 18G

I do "checkpoint" on the database and backup the log again. this should clear the log usage.

But I still see 3% from sqlperf(logspace) .

I check fn_dblog . and it's empty already.

why there are still 3% used ?

FETCH API_CURSOR

$
0
0

Hello,

We are using SQL Server 2016/Win2016

My templog is 99% full, when i checked the opentran, it came out to be 

Language Event0FETCH API_CURSOR0000000000026453

I query the sys.dm_exec_sql_text  and sys.dm_exec_cursors to find the actual sql text, but it doesnt return any output.

Please suggest

Thanks





Non-yielding Scheduler first time to happen on a new server

$
0
0

I have been running a stable database for 1 year and recently I moved to a new server that uses NVME drives.

Just after 3 days with the new server, I noticed the database performance is very slow and alot of dumps and event logs are being created

I am using Windows server 2016, MSSQL 2012 SP4 with latest updates.

I already tried DBCC checkdb with no errors and like I said the same configuration was stable for 1 year without a single crash and I just moved the same configuration to a new server that use NVME drives.

Process 0:0:0 (0x16e0) Worker 0x0000000CB3822160 appears to be non-yielding on Scheduler 2. Thread creation time: 13194934683908. Approx Thread CPU Used: kernel 1843 ms, user 15890093 ms. Process Utilization 78%%. System Idle 20%%. Interval: 19958666 ms.

Loading Dump File [D:\SQLDump0001\SQLDump0001.mdmp]
Comment: 'Program fault handler'
Comment: '02/18/19 05:37:21 spid 10 Exception 0xc0000005 EXCEPTION_ACCESS_VIOLATION reading address FFFFFFFFFFFFFFFF at 0x00007FFD409A9874
'
User Mini Dump File: Only registers, stack and portions of memory are available

************* Path validation summary **************
Response Time (ms) Location
Deferred srv*
Symbol search path is: srv*
Executable search path is:
Windows 8 Version 9200 MP (8 procs) Free x64
Product: Server, suite: TerminalServer SingleUserTS
Machine Name:
Debug session time: Mon Feb 18 05:37:22.000 2019 (UTC + 2:00)
System Uptime: 2 days 6:25:57.186

SQL Server CPU Performance

$
0
0

We've inherited some SQL server 2014 databases, they are running on Azure IaaS.  We're getting complaints about performance and trying to get a grip on it.  We're starting to look at CPU performance, and run the following test:

DECLARE @Loops INT SET @Loops=1 DECLARE @CPU INT SET @CPU=@@CPU_BUSY DECLARE @StartDate DATETIME SET @StartDate= GETDATE() WHILE @Loops<=100000BEGIN IF COALESCE('123','456')='456' PRINT 1 SET @Loops=@Loops+1 END

PRINT 'Total CPU time: '+ CONVERT(varchar,@@CPU_BUSY-@CPU) 
PRINT 'Total milliseconds: '+ CONVERT(varchar, DATEDIFF(ms,@StartDate, GETDATE()))
PRINT ''   
GO

On Production machine, 16 Virtual Processors (20 to 30% busy), we get the following result:

Total CPU time: 1150
Total milliseconds: 13473

On test machine, 4 Virtual Processors (also around 20 to 30% busy) we get the following:
Total CPU time: 2
Total milliseconds: 1183

I've tried running a few benchmarks on the production machine, but they don't show any problems, and always show the production machine CPU at least twice as powerful as test machine.

Is there some SQL Server setting that might be configured wrongly?  Any idea how to troubleshoot this issue?

Note the 'problem' database is running always on Availability Group, we are wondering if that may be a factor here.

Service pack with support for TLS 1.2

$
0
0

Hi

I will soon be installing service pack 3 for SQL server 2014 which has support for TLS 1.2

My SQL server is a Hotel with approx.10 different applications using it

There is a single application that needs to use TLS 1.2 (Mcafee), therefore this SP 3 installation

My question is following

Can I get connection problems from other applications after this SP3 installation when TLS 1.2 is activated / support

or will everything continue without problems

Regards Mogens

Not able to execute ssis package through stored procedure

$
0
0

Hi ,

Can you please help on below issue.

I'm unable to execute ssis package through stored procedure.I'm using sql server 2014 and data tools 2013.but same package it's running fine in bids,through cmd prompt.the account which I'm running is having sys admin role.

in ssis package I'm using script task.if I disable script task the sp is running fine.if I enable script task I'm getting error like

"   Code: 0x00000001
   Source: Script Task
   Description: Exception has been thrown by the target of an invocation.
End Error"

Reg:Count function differentiates from oracle to SQL server....

$
0
0

Hi Experts,

In Oracle i have table with the varchar columns a,b,c .

The below statement is there in oracle code.

select count(distinct a||b||c) from table.

so what is the equivalent of above  code in sql server?

Thanks in advance.


Error trying to perform update on linked server

$
0
0

I have set up a linked server and I am trying to perform an update on the remote server but I am getting the following error:

    OLE DB provider "SQLNCLI11" for linked server "remote_server" returned message "No transaction is active.".
    Msg 7391, Level 16, State 2, Line 1
    The operation could not be performed because OLE DB provider "SQLNCLI11" for linked server "remote_server" was unable to begin a distributed transaction.

I can execute a select query and that runs fine so I know I have set up the linked server correctly as far as that goes. After searching on the error I have found several suggestions and done the following for both main server and remote server: - Ensured the Distributed Transaction Coordinator service is running - In component services, ensured the following were set for local DTC: Network DTC access, Allow remote clients, Transaction manager communication allow inbound and outbound
 - Ensured Distributed Transaction Coordinator is allowed through the firewall
 - Restarted SQL server

I am now starting to wonder whether I can perform an update on a linked server or whether data is read-only.

Any help greatly appreciated.

J.

Not used condition in Execution plan

$
0
0

Hello, I have a problem with understanding execution plan of procedure. 

I run procedure, where we have IF clause 

IF(@ShowDetails = 1) Begin ....... End

I run 

exec prsp_some_proc  @ShowDetails  = 0

and in execution plan I see that 75 % of cost has spent on that IF condition.

When I put "print 'ok'" after IF, between BEGIN - END, its not printed, I mean that SQL is not entered in that section.

Could you please clarify for me, execution plan shows all clauses in the script, even if they haven't run, or only those that have been executed.
Thanks.


Xevent Lock_timeout

$
0
0

I have an xevent trace and found there are many lock timeout on tempdb . How to get details what are theses ?

How can i achieve the IF NOT statement with boolean value in sql server...

$
0
0

Hi Experts,

How can i achieve my below requirement in sql server..

currently it is throwing some syntactical errors while executing in sql server..

 
Declare @isAllSearch bit

SET  @isAllSearch='TRUE';

 IF NOT @isAllSearch THEN

 BEGIN

 print 'hai'

 END

 ELSE

 BEGIN

 print 'Bye'
 END

Thnaks,

Ramesh .

Reg: Why My SSMS get stuck suddenly while i am editing the code in the stored procedure...

$
0
0

Hi Experts,

My SSMS get stuck while i am editing the big stored procedure having the several lines of code through SSMS in alter mode.

when i saw the Task manager ,it shows that SSMS is taking more memory as shown in pic.

Can any one suggest what is the root cause and work around for this problem..

Thanks,

Ramesh.

best method , upgrade path from Access 2007 adp/ade linked to ms sql to Access 2016 or Access 2019

$
0
0

Can I upgrade Access 2007 adp/ade connected to MS SQL server to Access 2016 or Access 2019?

no old code, no activeX etc. new methods, but has lots of reports and forms.

methods to use, items to look out for?

thanks, John


Error in SP_READERRORLOG

$
0
0

SQL 2014 SP3 CU2 Default Instance

I'm getting the following error when executing SP_READERRORLOG

Msg 22004, Level 16, State 1, Line 0
Failed to open loopback connection. Please see event log for more information.
Msg 22004, Level 16, State 1, Line 0
error log location not found

This is a test; it is a Default Instance and is not on default port number (1433). It is running on port # 2019. I also noticed as soon as I change the TCP/IP port number to 1433, the SP_READERRORLOG executed successfully.

Any suggestions on how to execute SP_READERRORLOG with different default port number?

Viewing all 12644 articles
Browse latest View live


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