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

High CPU Utilization

$
0
0

Hi..

One of my SQL server taking more CPU on server. How can we check exact query or SQL server process taking more CPU.

As I know we can check in sys.sysprocesses system object, sp_who2 active and activity monitoring. But I am not sure is it gives correct CPU usage.

So please let me know how to find out which particular session is taking more CPU??


not connecting to mssql server 2012 after Installation

$
0
0

Hi

I am facing problem since yesterday. Not able to connect to msmssql server 2012

On my laptop server name 2012 taken itself. but on PC server name is empty and when I put Computer-name\instancename 

"Lenovo\MSSQLSERVER" then this message come

Cannot connect to MSSQLSERVER.

===================================

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (.Net SqlClient Data Provider)

------------------------------
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=53&LinkId=20476

------------------------------
Error Number: 53
Severity: 20
State: 0


------------------------------
Program Location:

   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover)
   at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
   at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
   at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
   at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.Open()
   at Microsoft.SqlServer.Management.SqlStudio.Explorer.ObjectExplorerService.ValidateConnection(UIConnectionInfo ci, IServerType server)
   at Microsoft.SqlServer.Management.UI.ConnectionDlg.Connector.ConnectionThreadUser()

===================================

The network path was not found

Please help

I will be grateful.

SQL Server Jobs & Schedules

$
0
0

Good Morning All

Does anyone know of a script/method of where I can obtain the following SQL Server Agent Job Information: -

Job Name, Owner, Description, Enabled, Schedule Description, Last Run

I've just joined another company and I've been tasked with auditing the SQL Servers here as this has never been done before.

Many thanks


Please click "Mark As Answer" if my post helped. Tony C.

SQL Server backup Compression

$
0
0

Hi,

How SQL server backup compression works?

1.  First sql server will allocate the space for backup and then will it compress ? 

2. Or it will allocate the space after calculating the compression space ?

And,

I have 3 TB database, the size of backup comes around 2.3 TB. I don't have drive space to hold the backup.

Is there any way to make backup into chunks ?

If so how to restore if i want in future ?

Thanks.

Vinodh Selvaraj


Rename a database

$
0
0

This seems like it should be easy, but...

I want to rename a database (from Inventory to Inventory_Bak) and then restore a newer copy of that database (Inventory) from another source. When I rename the database it doesn't change the physical MDF and LDF filenames, so when I try to restore I get the error:

"Restore failed...Inventory.MDF cannot be overwritten. It is being used by database 'Inventory_Bak'. "

How can I rename both the logical and physical names of my database?


Darrell H Burns

SQL server agent job running as Agent Service Account whose service account does not have r/w access but is still able to write?

$
0
0

Hi. I am newer to SQL server security and am reviewing some of our SQL server's configuration to make sure the services are running under accounts with least privilege.  I have a SQL server 2012 instance whose Agent service is configured to run under an AD user account named 'SQLServices'.  The jobs on this server are configured to run as 'SQL server agent service account', which means they should execute as user 'SQLServices'.  The jobs are set up to execute SSIS packages which read and write to a database on the same server where the agent job is scheduled and SSIS package installed (all on same server).  The jobs are currently executing without error and are reading writing data correctly.  Upon close examination, it turns out the SQLServices account is not assigned to the 'sysadmin' role and had no users mapped to any databases on this server.  How are these jobs working?  I verified in profiler that the login name indeed is 'SqlServices'.  I also verified that SQLServices login has no database access by remote-ing onto the server and trying to log into the DB, and access was denied as expected.  According to the literature, the Agent service needs to be a member of 'sysadmin role' but I am reading some cases where that is not necessarily the case.  So this is not so concerning.  What is concerning is that the login 'SQLServices' had no access to the databases on that server yet it is reading and writing to the databases as if it does.  The only thing I can think of is maybe jobs run as 'SQL server agent service account' on the same server as the databases it r/w to somehow has some kind of default access.  What am I missing here?  Any input would be helpful.

2014 In-Memory Table Bucket Size for varchar column

$
0
0

i'm trying to create an In-Memory Table with a hash index on a varchar column. If you have a numeric field, it's supposed to be twice the unique values, but how do you calculate the BUCKET_COUNT for a varchar(20) column? I've an Email column and i want to create an index on it but i don't know what the BUCKET_COUNT should be... i cannot find any help about it, every tutorial or help explains hash indexes with numeric values only. 

thanks!

Cannot generate sspi context error

$
0
0

Hello,

I am using SQLServer 2012 SE in Windows 2012 Data Center Edition.

When I am trying to connect to sql server from ssms from different machines (my laptop or some other workstations from office) I am getting the below error.



This only happens if I using AD account to connect to SQLServer. If I choose sql server authentication then I am able to connect without any error. I restarted the services and also rebooted the server but no luck. I even tried deleting the spn and setting it up but it did not help. All the users are having this issue. Most of them are sysadmins on this sqlserver .

Can someone help fix this error?

Thanks a ton


Backup Huge SQL Database (500GB) and copy it to a 3rd party system.

$
0
0

Hello All,

I have a situation as explained below:

1. Backup a 500gb sql database (can the backup be split into multiple files).
2. Copy it over the network to a third party datacenter (in a different network), in the safest way.

Assuming i will have a Network connectivity to this 3rd Party Site.
3. Restore the copied backup to a sql instance on new datacenter.
4. Run both instances of sql (in existing datacenter and new third party datacenter) and keep in sync for a day or two, until we fully cutover.

I would need help to get some opinions on each of the above points, to get the best possible fastest and safest way to achieve these.


Vinish Viswanathan

SQL IO Error on New server!!

$
0
0

Recently we upgraded SQL instance and after upgrade there are errors reported in sql errorlogs .

SQL Server has encountered 1 occurrence(s) of I/O requests taking longer than 15 seconds to complete on file 


SQL job cancelled alert

$
0
0

Hi All. There is a maintenance job for SQL databases backup, and somethings when somebody don't know the backup job is running then reboot the server, the job is cancelled without any notice. And after some time DBA notified lately the job is cancelled by reboot.

are there any function for SQL agent jobs send out alert for canceled job?

Accidently BUILTIN\Administrators is removed - Please help

$
0
0

Accidently "BUILTIN\Administrators" account is removed from sql-2005.

Please help how can I re-add it...


--------------------------------- Devender Bijania

Querying on Maintenance Plan's content tables

$
0
0

Hello,

Currently, i'm trying to know if there is any task in any maintenance plan for a specific database name on SQL Server 2008 and so on. I want to do it for doing a performance check-up of my server and of my associated website (asp.net).

I'm able to know if there is any maintenance plan and their name and associated subplans' name but i can't retrieve any details of it.

Here, a query which get a list of all Maintenance Plan on a database server :

SELECT 
   p.name                                      as 'Maintenance Plan'
   ,isnull(p.[description],'')                as 'Description'
   ,p.[owner]                                  as 'Plan Owner'
   ,sp.subplan_name                        as 'Subplan Name'
   ,sp.subplan_description              as 'Subplan Description'
   ,j.name                                    as 'Job Name'
   ,j.[description]                            as 'Job Description'  
FROM msdb..sysmaintplan_plans p
   INNER JOIN msdb..sysmaintplan_subplans sp   ON p.id = sp.plan_id
   INNER JOIN msdb..sysjobs j                  ON sp.job_id = j.job_id
WHERE j.[enabled] = 1

Thanks for all your help.

Cardinality estimator 2014 is off with OR in where clause

$
0
0

Here is my test setup on SQL Server 2014.

-- Create big table
CREATE TABLE [dbo].[Store](
	Id int IDENTITY(1,1) NOT NULL,
	City int NOT NULL,
	Size int NOT NULL,
	Name varchar(max) NULL,
    CONSTRAINT [PK_Store] PRIMARY KEY CLUSTERED ([Id] ASC)
 )
GO
CREATE NONCLUSTERED INDEX [IX_Store] ON [dbo].[Store] (City ASC, Size ASC)
GO
-- Fill with 100k rows
INSERT Store
SELECT i % 101, i % 11, 'Store ' + CAST(i AS VARCHAR)
  FROM
 (SELECT TOP 100000 ROW_NUMBER() OVER (ORDER BY s1.[object_id]) AS i
  FROM sys.all_objects  s1, sys.all_objects  s2) numbers
GO

-- Create small table
CREATE TABLE #StoreRequest (City int NOT NULL, Size int NOT NULL)
GO
INSERT #StoreRequest values (55, 1)
INSERT #StoreRequest values (66, 2)

Now I execute the following query (I force the index to show statistics estimates)

SELECT s.City
  FROM #StoreRequest AS r
       INNER JOIN Store AS s  WITH(INDEX(IX_Store), FORCESEEK)
       ON s.City = r.City AND s.Size = r.Size
 WHERE s.Size <> 1 OR r.City <> 55

Here are the estimates that I get (I'm not allowed to upload pictures):
Index Seek IX_Store
Actual Number of Rows: 90
Estimated Number of Rows: 50000

Fixing WHERE clause to use one table not two makes the estimate perfect:

SELECT s.City FROM #StoreRequest AS r INNER JOIN Store AS s WITH(INDEX(IX_Store), FORCESEEK) ON s.City = r.City AND s.Size = r.Size WHERE s.Size <> 1 OR s.City <> 55

Index Seek IX_Store
Actual Number of Rows: 90
Estimated Number of Rows: 89.74

Switching to 2012 compatibility mode gives estimate of 1 in both cases:

Index Seek IX_Store
Actual Number of Rows: 90
Estimated Number of Rows: 1

Could anyone explain the first result? I'm a bit worried about it. The fix in this case is trivial, but this problem gave us quite some headache in more complex real life queries with multiple joins.

Thank you!


Full-text search not available after upgrade from SQL 2008 R2 Std to SQL 2012 Std

$
0
0

We upgraded our production SQL Server from 2008 R2 Std to 2012 Std last week, and the installation logs show everything was successful, but now we are unable to do any searches against our full-text indexes.  The resulting error is as follows:

"Full-Text Search is not installed, or a full-text component cannot be loaded."

When executing the query "SELECT FULLTEXTSERVICEPROPERTY('ISFULLTEXTINSTALLED')", the result is "0".  The "Full-Text Daemon Launcher service is also running.  When running installation again to add the feature, it shows"Full-Text and Semantic Extractions for Search" as being installed and unavailable for selection in the list of features to add.  As a side note, we did the same upgrade in our identical QA environment before production and everything was successful and full-text searches are working correctly.  We have run the "Repair" routine in the SQL Installation Center and it did not correct the problem.

The full-text catalogs still appear when browsing through the GUI in SSMS or querying sys.fulltext_indexes and sys.fulltext_index_columns.  It is not possible to view the properties of the catalog in SSMS, though, as the GUI throws an error and an empty dialog box is shown.  Any other thoughts?

Thanks,

AJ


Loading sql native format data file exported using bcp command in Oracle

$
0
0

Hi All,

We have 10 tables in sql server with around 30 million rows. We intend to load these tables in Oracle database by exporting them using bcp native data format export. Is it possible to load sql native data format files in Oracle? If so how can ispecify row and column separators?

ssis or any other tools is not an option.

TIA

Help! SQL server database log file increasing enormously

$
0
0

I have 5 SSIS jobs running in sql server job agent and some of them are pulling transactional data into our database over the interval of 4 hours frequently. The problem is log file of our database is growing rapidly which means in a day, it eats up 160GB of disk space. Since our requirement dont need In-point recovery, so I set the recovery model to SIMPLE, eventhough I set it to SIMPLE, the log data consumes more than 160GB in a day. Because of disk full, the scheduled jobs getting failed often.Temporarily I am doing DETACH approach to cleanup the log.

FYI: All the SSIS packages in the job is using Transaction on some tasks. for eg. Sequence Cointainer

I want a permanent solution to keep log file in a particular memory limit and as I said earlier I dont want my log data for future In-Point recovery, so no need to take log backup at all.

And one more problem is that in our database,the transactional table has 10 million records in it and some master tables have over 1000 records on them but our mdf file size is about 50 GB now.I dont believe that this 10 million records should make it to 50GB memory consumption.Whats the problem here?

Help me on these issues. Thanks in advance.

SQL Server 2008 Dump Transaction

$
0
0

I used SQL Server 2005 before and used "DUMP TRANSACTION ... WITH NO_LOG" statement, i tried to do same  thing in SQL Server 2008 and it doesn't work. How can i use it in SQL Server 2008?

I used with rollup to add a Grand Total in the result.

$
0
0

BEGIN select a.InvoiceNumber ,a.InvoiceDate,dbo.GetCompanyName(CompanyId) Company,isnull(convert(VARCHAR,a.InvoiceNumber),

'GRAND TOTAL') AS InvoiceNumber, sum((Sum(isnull(Units,0)*isnull(UnitPrice,0))+ isnull(a.GST,0))) AS 'Total In Inventory',

(Select ProjectCode from tblProjectmmc where id=ProjectId)as ProjectId,a.BusinessUnit,(Sum(isnull(Units,0)*isnull(UnitPrice,0))+ isnull(a.GST,0))

as InvoiceAmount, a.UserId as ProjectManager from tblinvoicemmc a inner join tblInvoiceItemDescriptionmmc b

on a.InvoiceNumber=b.InvoiceNumber group by a.invoicenumber,a.GST,a.InvoiceDate,a.CompanyId,a.ProjectId,a.UserId,a.BusinessUnit with rollup

ORDER BY a.Invoicenumber DESC ; End

but giving error


Cannot perform an aggregate function on an expression containing an aggregate or a subquery.


Sms


How to delete the Folder from sql server 2008

$
0
0

Hi all,

I was trying to delete the folder from sql server 2008 with the below script

DECLARE @path VARCHAR(256) -- path for backup files

DECLARE @cmd VARCHAR(8000)

DECLARE @folderName VARCHAR(256) -- filename for backup


SET @folderName = + (CONVERT(varchar(10), GETDATE()-7, 112))  -- 7 days back date folder name
SET @path = 'I:\Backup_Test\' + @folderName -- Folder path
SET @cmd = 'del ' + @path -- Delete

EXEC master..xp_cmdshell @cmd

--Print @cmd

 

 

This is not working it was asking the Confirmation (I:\Backup_Test\20100629\*, Are you sure (Y/N)? ) what will i do to the delete the folder.

Thanks,

Prasad R.

 

Viewing all 15264 articles
Browse latest View live


Latest Images

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