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

SQl Server 2008 R2- Geeting SQl Server Result in to Excel file

$
0
0

HI !!!

I am working with SQL Server 2008 R2 .

I have table named dailysalesReport which contains Thousand of data on daily basis.

I need when I execute the select statement then result automatically saved in a excel sheet.

Kindly someone help me out.

Regard's

Manjeet


How to resolve RESOURCE_SEMAPHORE and RESOURCE_SEMAPHORE_QUERY_COMPILE wait types

$
0
0

We are trying to figure out root cause of slow running sql server queries hitting/fetching data from one of the database , size 300 GB, hosted on server with below configuration:

Windows server 2003 R2, SP2, Enterprise Edition, 16 GB RAM , 12 CPU'S 32 Bit

SQL server 2005, SP4, Enterprise Edition, 32 Bit.

We have already informed business on the upgrade to 64 bit which would take over a month.

But for the current issue, we are trying to gather the data if we can resolve the memory pressure or finally come to a conclusion to increase RAM.

Action Completed: Re-indexing and update stats are proper for this DB.

As shown below, we have been noticing the semaphore waittype for past 5 days, ran during the load hours:

Few info after below queries: size of buffer= 137272

SELECT SUM(virtual_memory_committed_kb)FROM sys.dm_os_memory_clerksWHERE type='MEMORYCLERK_SQLBUFFERPOOL'

and semaphore memory= 644024 per below query

SELECT SUM(total_memory_kb)FROM sys.dm_exec_query_resource_semaphores

Below is some more info gathered from dm_exec_query_resource_semaphores and sys.dm_exec_query_memory_grants dmv's

So from above info gathered and per SP_Blitz data Resource semaphore seems to be the problem.

Is memory 'target_memory_kb' assigned for resource semaphore id's too low, as compared to 16 GB RAM available.

Note* per analysis on 8 hours run 'target_memory_kb' is always under 1 GB, compared to 16 GB available?

what could be the issue here and how to resolve, please suggest

Thanks

Checkpoint operation failed. Error: 41315

$
0
0

Hello!

All started when  Sql server error log shows:
The transaction log for database 'databasename' is full due to 'XTP_CHECKPOINT'.
On database which uses as usually 30GB log file. 
The LOG file now is 400GB

After searching during 2 days I found too little information(((

It seems, that I have the same problem like in this link, log is growing.
https://connect.microsoft.com/SQLServer/feedback/details/1021865

Microsoft SQL Server 2014 - 12.0.2456.0 
Database in SIMPLE recovery, 
DBCC LOGINFO shows many rows with  State=2
DBCC OPENTRAN show 0 transactions
SYS.DATABASES.log_reuse_wait_desc = XTP_CHECKPOINT
No replications
In-Memory enabled and used
Manual CHECKPOINT shows the error:

Error: 41315, Severity: 16, Checkpoint operation failed.

Is anybody catches the same errors before?

PS. I have restored Database and can run CHECKPOINT command and shrink database. But in several minutes I can't repeat this again because of the sameCHECKPOINT error.

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

The same not resolved threads:

I can not shrink transaction log , please help me.

 https://social.technet.microsoft.com/Forums/en-US/5a1926b7-cef4-4b64-a06f-e1927dedfe71/i-can-not-shrink-transaction-log-please-help-me?forum=sqldatabaseengine and this :

Log not truncating due to xpt_checkpoint

https://social.technet.microsoft.com/Forums/en-US/4914e549-3f7a-4be1-83e2-442e22a07dc2/log-not-truncating-due-to-xptcheckpoint?forum=sqldatabaseengine

CHECKDB found 0 allocation errors and 1 consistency errors in table 'sys.syscolpars' (object ID 41)

$
0
0

Msg 2511, Level 16, State 2, Line 1
Table error: Object ID 41, index ID 1, partition ID 281474979397632, alloc unit ID 281474979397632 (type In-row data). Keys out of order on page (1:187), slots 9 and 10.
CHECKDB found 0 allocation errors and 1 consistency errors in table 'sys.syscolpars' (object ID 41).
CHECKDB found 0 allocation errors and 1 consistency errors in database 'db_name'.
repair_rebuild is the minimum repair level for the errors found by DBCC CHECKDB (adv_tvs).

Help required on the above error mentioned

Backup table

$
0
0

Hi,

I need to take the backup of some tables in Production. I may have to restore these backups.

Please let me know how to do it (backup of single table and how to restore it in case if needed)

I am using SQL Server 2012.

REgards




Can we enable file streaming capability in Sql server 2008R2 clustered instance?

$
0
0

Hi,

We are having a Sql Clustered instance of SqlServer 2008 R2 running
on windows server 2008 R2 with 2 nodes. We have about 88 databases in the instance.
Our servers run on Intel Xeon(R) CPU X5670 @2.94 GHz with 6 cores(12 logical processor).
The servers are having 12GB of RAM.Our network storage is in EMC and for data we are having
a shared voume of 2 TB for the data(for both mdf and ldf files). I would like to know
whether there would be any problem in enabling file streaming through GUI in the clustered
instance. I understand that by creating a table with a file stream coloumn would create a
subfolder in the file stream data container. Once we created a shared folder in the shared
volume(lun) and there was a server reboot in the active node. Should be anticipate any such eventuality.
Are the steps of enabling file stream capability in the clustered instance same as that of enabling it
in a noram instance?

Thanking you in anticipation,

Binny Mathew

Performance counters missing for single database

$
0
0

Hi,

I've been sent a new version of a database by our data vendor, which is a .mdf file to attach.  The vendor has a service that downloads data and inserts it into this database, which we then query.

I detatched the old database and then attached the files they had supplied.  This all works fine.

But the new database does not have performance counters.  How can I create performance counters for a single database?

To be clear, I've tried unloading and reloading the counters and it doesn't solve the problem.  The counters for all the other databases on the server show just fine.  It's just this one database that is missing.  Subsequent detatch and re-attach do not recreate the counters.

Thanks,

Error [36, 17, 145] occurred while attempting to drop allocation unit ID

$
0
0

Error [36, 17, 145] occurred while attempting to drop allocation unit ID 430989268287488 belonging to worktable with partition ID 430989268287488.

Error saw in mssql 2012 enterprise edition service pack 1. os:- windows server 2012..

Any solution team.



Trending database sizes, is there a tool to do this?

$
0
0

Hi, 

Was wondering if there's a tool for monitoring database file growth.  I've been reading up on a number of user created solutions to collect data on a daily basis but wondered if there was any professional software solution for this.  I've a number of RedGate tools but none seem to cover this.  

Thanks 

Read portion of Transaction Log inculded in Full Backup.

$
0
0

Hello,

 I am wondering if there is any way we can read the 'transaction log' part from the full backup.
 A Full backup backup contains some part of the transaction log - minimum(oldest active transaction,replication txn)
 
 So, is there any native way to read the portion of the 'transaction log' inculded in the full backup.
 
 Using fn_db_dumplog we can read the log backups and using fn_dblog we can read the logs.
 
 but i am curious to see if there is anyway to read the 'transaction log' that was inculded in the full backup.
 
 
 Thank you. 
 
 

Hope it Helps!!

Does a temp table is reuired to insert into a table

$
0
0

Hi ,

I am using a stored procedure to check the availability of a record in a table and deleting the record if exists ,

actually  if the user have multiple record i need to delete and store it in removed table  , so i used insert with select command to insert into the table , do i need to use a temp table to insert multiple record in removed table .

Thank You

Jeevan Vinay

Message Queue with SP executing xp_cmdshell not working in after DB migration

$
0
0

We are in a Database Migration Project.

DatabaseA is set to be migrated. It currently resides in ServerA. In DatabaseA lies an SP, which calls XP_CMDSHELL in it. This SP is being called by a messageQueue.

In ServerA, we do have a Local Windows System user as the application login. ( ServerA\LocalLogin). This login  does not have any sysadmin privileges and only is a member of db_datareader and a custom executesp roles of the DatabaseA.

This database Needs to be migrated to ServerB. when migrating this to ServerB, the only change is that the LocalSystem user is replaced by a Domain User. The application is supposed to connect to the DatabaseA via the Domain User. (Domain\DomainUserB)

However, Once the database is migrated to ServerB, we get the following error related to the message queue:

The xp_cmdshell proxy account information cannot be retrieved or is invalid. Verify that the '##xp_cmdshell_proxy_account##' credential exists and contains valid information Message Queue Service Broker

This error never happen to come in ServerA and  is no proxy_accounts are configured in it. The logins (ServerA\LocalLogin and Domain\DomainUserB)  are identical in terms of privileges. What would be the problem ? Why is this error popping only in ServerB ? How can i overcome this without creating a proxy account ?

Security Context of the MessageQueue is  ExecuteAsUser with a principal of dbo.

Both the servers are SQL Server 2008, and Windows Server 2008.


DBCC Page - Shows Uncommitted data??

$
0
0

Hello,

 I am doing some internal testing to learn how dbcc page reads the data and I find it strange that I can see uncommitted data on the page. 

 I am not sure why i would see that information.  My initial thought was may be check points, wrote the data on the page and I set the recovery intervals high (test system) and started a extended events trace to monitor check points and Check point were not issued during this period but I still see the uncommitted reads.

 I do not think it because of lazy writer either. can someone please explain on this.

 you can try the below demo to reproduce the issue.

Create Database SSMS2012
GO
USE SSMS2012
go
Create Table SSMSt(sno int primary key identity(1,1),sname varchar(6))
go
Insert into SSMSt
values('Better')
go 100


select * from sys.dm_db_database_page_allocations(db_ID('SSMS2012'),object_ID('SSMSt'),null,null,'limited')


dbcc traceon(3604,-1)
--use the allocated_page_page_id where is_iam_page=0
dbcc page(5,1,228,2)

--sesssion 2 . see the data is not committed yet.
begin tran
update ssmst set sname='qazxsi'

--session 1
--run the dbcc page again. we can see the new uncommitted data.
dbcc page(5,1,228,2)

clean up
--session 2
Commit
use [Master]
go
--Session 1
use master
go
Drop database SSMS2012
Thank You.
  

Hope it Helps!!

Database in Emergency Mode

$
0
0

Hi All.. i have had one database was in suspect mode and i have changed the status to Emergency Mode and  i have run the DBCC checkdb and command didn't gave any error.. after this i have tried to change database to Single_user mode, but command running successfully, but database status is still showing as Emergency mode only.. i have tried for multi_user mode too..

Also, i have tried to run the command to bring online, but command running for long time with Suspended status..

Could anyone help me on this??

daily job performance improved by sql service restart - why?

$
0
0

We have a daily job which generally takes around 12 hours. After a couple of weeks the duration starts to creep up and we are able to restore it to its normal duration by restarting the sql server service.

Why does restarting the service seem to speed up the job? seems a little like using a bulldozer to crack a nut. Would like to understand what exactly is happening when we restart to improve the duration. Any ideas?


SPID stuck in KILLED/ROLLBACK state

$
0
0

Hi All,

SQL Server 2008R2 (10.50.4279) I've noticed a process that hungs, the wait type was "PREEMPTIVE_OS_PIPEOS" and the process itself was a SQL Server Agent job.

First thing is that in Job Activity monitor I could not see any job running.

I've tried to kill the spid from Activity monitor but now the SPID is stuck in "KILLED/ROLLBACK" state, and the wait is always "PREEMPTIVE_OS_PIPEOS".

I've checked that the job executes a stored procedure that invokes sp_send_dbmail with an attachment, I've tried to restart the SQL Server Agent, but the spid is always there.

How can I kill the process?

SQL DB Migration

$
0
0

Hi,

In my infra i have an instance with 10 Databases. And i am going to migrate 4 of them to new hardware.

I am planning to use Backup/Restore method to move the DBs to new hardware.

I will put the DBs in old server to SINGLE_USER mode. 

Can you please tell me how to check the complete data is migrated to new server ?

I dont want to miss any transactions (data) from application.

And also how to compare the data between the old and new DBs ?

Regards,


Vinodh Selvaraj

Change SQL server instance collation after Sharepoint installation

$
0
0
Installed Sharepoint 2013 with the SQL Server 2012 db instance using the default collation Latin1_General_CI_AS. SQL is just used for Sharepoint 2013. the system is not released yet for production Run the installation and configurations and database attach for all content databases. all content dbs were created by SP with proper collation Latin1_General_CI_AS_KS_WS, as well as search, UP and all service applications.
Would like to change the SQL collation for the instance to Latin1_General_CI_AS_KS_WS(ashttps://support.microsoft.com/en-us/kb/2008668) . Steps that I see:
1. Stop IIS on SP
2. Script logins
3. recreate instance collation
setup /QUIET /ACTION=REBUILDDATABASE /INSTANCENAME=<Name> /SQLSYSADMINACCOUNTS=<Sysadmins> /SAPWD=PasswordSA /SQLCOLLATION=Latin1_General_CI_AS_KS_WS
4.recreate logins (including Sharepoint farm, portal and services service accounts) from previous scripts. Redeploy linked servers ,remote logins,endpoints, backup devices
4. attach all Sharepoint databases
5. since it is preproduction not need msdb also model can remain as recreated by setup
do you see any issue?

Needed transaction log space to create a clustered index.

$
0
0

On a database a number of indexes are missing. It is killing the performance of the SQL Server. I want to create a clustered index on the biggest table that has as size of 1TB. How much transaction log space is needed to create the clustered index?

Is it possible to reduce the amount of transaction log space that is needed?

Does the size of the selected fields make a difference?

SQL Server 2012 CLR allocations problem

$
0
0

Hello everybody!

After upgrading from Microsoft SQL Server 2008 to Microsoft SQL Server 2012 we faced with CLR allocations problem. In earlier versions of SQL Server CLR allocations were in virtual address space (also known as "Memory-To-Leave"). In SQL Server 2008 you can configure max_server_memory for SQL server, prevent starting other processes on server and it will guaranty you that your CLR will not unload due memory pressure (use “lock pages in memory”)

In SQL Server 2012 there were big changes in memory management.  The key change for us was relocating (or splitting) CLR allocations from "Memory-To-Leave" to "max server memory (MB)". And now you can get “AppDomain 2 (work5nt.dbo[runtime].1) is marked for unload due to memory pressure.” message in server log  with future unloading AppDomain when “Query Execution Memory” grows fast.

During our stress tests of SQL server 2012 I had rapid growth of “Granted Workspace Memory (KB)” to more than 50% of max_server_memory (72GB). Top wait on server was RESOURCE_SEMAPHORE and «SQL Memory Manager:Memory Grants Pending»  growth up to 154 processes.

Information from log file about unloading:

2015-03-26 19:49:20.15 spid18s     AppDomain 13 (work5nt.dbo[runtime].82) is marked for unload due to memory pressure.

2015-03-26 19:49:20.15 spid18s     AppDomain 12 (mssqlsystemresource.dbo[runtime].81) is marked for unload due to memory pressure.

2015-03-26 19:49:20.15 spid19s     AppDomain 13 (work5nt.dbo[runtime].82) unloaded.

2015-03-26 19:49:20.15 spid18s     AppDomain 12 (mssqlsystemresource.dbo[runtime].81) unloaded.

2015-03-26 19:49:20.83 spid419     AppDomain 14 (work5nt.dbo[runtime].94) created.

2015-03-26 19:49:20.86 spid245     Unsafe assembly 'log, version=1.0.5498.27124, culture=neutral, publickeytoken=bb8adbf0186b255f, processorarchitecture=msil' loaded into appdomain 14 (work5nt.dbo[runtime].94).

2015-03-26 19:49:20.86 spid419     Unsafe assembly 'seed, version=1.0.5539.32591, culture=neutral, publickeytoken=4d4e4ff7fd85d31c, processorarchitecture=msil' loaded into appdomain 14 (work5nt.dbo[runtime].94).

2015-03-26 19:49:20.89 spid245     Unsafe assembly 'log, version=1.0.5498.27124, culture=neutral, publickeytoken=bb8adbf0186b255f, processorarchitecture=msil' loaded into appdomain 14 (work5nt.dbo[runtime].94).

2015-03-26 19:49:20.91 spid419     Unsafe assembly 'seed, version=1.0.5539.32591, culture=neutral, publickeytoken=4d4e4ff7fd85d31c, processorarchitecture=msil' loaded into appdomain 14 (work5nt.dbo[runtime].94).

 

Our product can get critical error after unloading CLR. (We are working on that problem but it’s not SQL server side problem.)

 

Main memory counters during stress test (perfmon):

Name

Average

Min

Max

Total Server Memory (KB)

75 783 960

75 774 432

75 880 536

ReservedServerMemory (KB)

18 474 365

9 028 744

35 325 584

GrantedWorkspaceMemory (KB):

27 173 700

16 992 392

51 791 136

Reserved/Granted Ratio

0.68

0.53

0.68

So we can see, that highest Reserved Server Memory more than 46% of Total Server Memory! And it is strange.

At the end I have several questions:

Here the first one: How can I avoid unloading CLR due memory pressure on SQL server 2012?

Second one: Can I configure “Reserved Server Memory” for query or server?

And the last one: Is there any extended events to reveal which query consumed a lot of memory? I found sort_memory_grant_adjustment but it does not work or I can’t configure it right.

 

About my system:

Servers HP Proliant BL620c G7

Duble 3PAR StoreServ Storage 7200 with remote copy “on” and adaptive optimization “on”

Virtualization:ESXi 5.5.0, 2302651

Software:

Microsoft Windows 2008 Server R2 Enterprise 7601

Microsoft SQL Server 2012 - 11.0.5058.0 Enterprise Edition (64-bit)  SP2

VM:

Xenon E7-2870 @2.40 GHz 16 cores (2 sockets, 8 cores), RAM 80GB.

SQL Server memory configure:

max server memory (MB) 74000

min memory per query (KB) 2048

minservermemory (MB)  128

sql server starts with  -T 1222 -T 1224 -g 512,

Using locked pages in the memory manager,

Large Page Allocated: 32MB,

CLR version v4.0.30319

  

If you need more information please feel free to contact with me.

Viewing all 12554 articles
Browse latest View live


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