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

index based value return

$
0
0

i have a string '2,4,6,8,10' in sql server when i enter the index value that means (1,2,3,4,5)  i  want to output  with respect to index position

i want a output like below:

if index=1 then value=2

if index=1 then value=4

if index=1 then value=6

if index=1 then value=8

if index=1 then value=10


SQL SERVER 2012 Installed to SMB share Error 59 (An unexpected network error occurred)

$
0
0

I have installed SQL 2012 on a clustered file share. When I try to add space to extend the log file for a database I get the following error

Msg 5149, Level 16, State 3, Line 1
MODIFY FILE encountered operating system error 59(An unexpected network error occurred.) while attempting to expand the physical file '\\server\share\path to ldf file.ldf'

The SQL service is running under a local domain account that does not have administrator rights to the system.  The service account does have full disk and share permissions and the service starts without any problems.  I have applied all the cluster hotfixes and all the current Windows Updates.  If I log into the system as the SQL service domain user account I can access the share and have full rights to it.

Any help would be appreciated.

Thanks,

A timeout (30000 milliseconds) was reached while waiting for a transaction response from the MSSQL$XXXXX service.

$
0
0

Sometimes we have problem with SQL databases: applications lost connection to database and in application log we have message like this

Log Name:      Application
Source:        Report Server (XXXXXX)
Date:          23.03.2016 13:02:53
Event ID:      107
Task Category: Management
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      XXXXXX
Description:
Report Server (XXXXXX) cannot connect to the report server database.

In the same time in system log there is this message:

Log Name:      System
Source:        Service Control Manager
Date:          23.03.2016 13:03:20
Event ID:      7011
Task Category: None
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      XXXXXXX
Description:
A timeout (30000 milliseconds) was reached while waiting for a transaction response from the MSSQL$XXXX service.

What can be a problem? How to find out probable cause?

Understanding SERIALIZABLE

$
0
0

Hi all of you,

First SSMS query session:

DECLARE @Result AS TABLE
(
  actid INT,
  mx    MONEY
);

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; DECLARE @actid AS INT, @val AS MONEY, @prevactid AS INT, @prevval AS MONEY; DECLARE tx_cursor CURSOR FAST_FORWARD FOR SELECT actid, val FROM dbo.Transactions ORDER BY actid, val; OPEN tx_cursor; FETCH NEXT FROM tx_cursor INTO @actid, @val; SELECT @prevactid = @actid, @prevval = @val; WHILE @@FETCH_STATUS = 0 BEGIN IF @actid <> @prevactid INSERT INTO @Result(actid, mx) VALUES(@prevactid, @prevval); SELECT @prevactid = @actid, @prevval = @val; FETCH NEXT FROM tx_cursor INTO @actid, @val; END IF @prevactid IS NOT NULL INSERT INTO @Result(actid, mx) VALUES(@prevactid, @prevval); CLOSE tx_cursor; DEALLOCATE tx_cursor; SELECT actid, mx FROM @Result; GO

Second SSMS query session:

SELECT TOP 100 actid
  FROM dbo.Transactions
  ORDER BY actid, val;

I do the following: debug the first one with F11 and at the same time before CLOSE and DEALLOCATE statements go to my second window and launch the SELECT TOP statement.. And? I get all the 100 first rows.

Why? isn't SERIALIZABLE the strongest isolation level?


SQL Agent Job Schedules Getting Skipped

$
0
0

Hi All,

Recently on Production Server, we observed some of the Job Schedules are getting skipped. I mean, jobs are not running as per scheduled. Can anyone tell what could be the reasons ??This is the first time we are seeing this in our environment.

We are running SQL Server 2012 sp1. We ruled out SQL was running, SQL Agent was running fine also it wasn't long running jobs. Job is scheduled every day midnight at 12:00 am and it takes an 1 hour to complete. Very difficult to troubleshoot this. 

Can anyone provide their inputs on this?

Thanks,

Sam

NUMA doubts

$
0
0

Hi SQL Experts,

Can anyone help in below queries.

What is NUMA? Why NUMA ? How it is related/affects SQL Server Performance?
How it affects the MAXDOP setting.

Please don't paste urls/links. I just wanted to understand in simple layman terms or short descriptions.

Thanks,

Sam

Restore of Full backup then a Differential backup failing on SqlServer 2012 SP3

$
0
0

Trying to restore a Production DB backup into a Test DB for some Development work

Have tried via the GUI and that consistently gives the error "Unable to create restore plan due to break in the LSN chain"

Tried using T-SQL with both the DB restore and Files Restore variations (Error below)
    Msg 3136, Level 16, State 1, Line 5
    This differential backup cannot be restored because the database has not been restored to the correct earlier state.
    Msg 3013, Level 16, State 1, Line 5
    RESTORE DATABASE is terminating abnormally.  

DB Method code:

USE [master]
RESTORE DATABASE [HR92JCN]
  FROM  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Backup\Save\HR92PRD_backup_2016_03_17_030000_6735302.bak'
  WITH  FILE = 1,  NORECOVERY, REPLACE
RESTORE DATABASE [HR92JCN]
  FROM  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Backup\Save\HR92PRD_backup_2016_03_22_000001_1000758.dff'
  WITH  FILE = 1,  RECOVERY, NOUNLOAD,  STATS = 5

GO


File method Code:
USE [master]
RESTORE DATABASE [HR92JCN]
  FROM  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Backup\Save\HR92PRD_backup_2016_03_17_030000_6735302.bak'
  WITH  FILE = 1,
  MOVE N'HRPRD_data' TO N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\HRJCN.mdf',
  MOVE N'HRPRD_log' TO N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\HRJCN.LDF',
  NORECOVERY,  NOUNLOAD,  REPLACE,  STATS = 5
RESTORE DATABASE [HR92JCN]
  FROM  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Backup\Save\HR92PRD_backup_2016_03_22_000001_1000758.dff'
  WITH  FILE = 1,
  MOVE N'HRPRD_data' TO N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\HRJCN.mdf',
  MOVE N'HRPRD_log' TO N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\HRJCN.LDF',
  RECOVERY,  NOUNLOAD,  REPLACE,  STATS = 5
GO

Thanks in advance for your help


John Nollet

Cannot use special principal 'dbo' 15405

$
0
0

Hi, 

Have a user who is db_owner of a database but they cannot access it.  I thought to drop the user and recreate, however this is not possible because of the error shown in the subject.  

There is a login at the instance level but no user in the database, however 'dbo' has this user as it's login. 

Any ideas? 


Different lock escalation behaviors in SQL 2014?

$
0
0

Our new SQL 2014 production system is seeing something new, some long-term blocking between SPIDs.

This is a migration up from SQL 2008R2.

Just starting to look at it, either the plans are different and we're getting some small blocks, or I suspect that we're getting more lock escalation in SQL 2014 and getting up to table locks.

Does anyone have any links or any direct observations of different lock/escalation/blocking behaviors in SQL 2014?

Thanks,

Josh

How can we get info about one column?

$
0
0

Hi everybody,

sp_help '<my_table>' return all the columns and constraints for the specified object

How can get the same but encompassing only the column desired?

Something like that:

sp_helpcolumn '<schema>.<my_table>.<my_column>

Thanks indeed for your time, happy coding!


I know that we have sys.columns DMO but I am thinking in some SP

Sql server timeout issues, Win32Exception (0x80004005): The wait operation timed out

$
0
0

Hi

In our production server a job is trying to insert into a table, occasionally fails with the below message

Job Failed ExceptionMessage:System.Data.SqlClient.SqlException (0x80131904): Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out
Line 1543:   "Body": "Failed persisting, ExceptionMessage:Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.;

On running sql profiler for that particular table we can not see any blocking or lock issues, but we see disk Q length spikes to 5,000++ due to another heavy store procedure running on a different table, also one thing we notice is service broker gets timeout at the same time, though the tables are different in all 3 executions timeout occurs how does the disk IO affects the each other, PLE is also extremely low.

So My question is will heavy store procedures(for table A) will affect the insertion for Table B and select for Table (C) although no one is related to each other by queries. Though we increase the timeout for ad-hoc queries still it gets time out..

If this is the case will resource governor will be a feasible solution?


Best Regards Moug

Setting Alert on Performance "Lock Timeouts (timeout > 0)/sec

$
0
0

I have a couple questions about this. I am using SQL Server 2014.  The database that has problems is less the 100 MB.  I will get how busy the server is later.

Background.  I am helping someone identify the source of intermittent timeouts.  My understanding is that their .Net applications are running fine most of the time.  But then the application begins timing out.  I haven't established yet whether this is a connection time out or whether the query times out (that will come later).  I am toying with the following approach.

I create an alert on Lock:Lock Timeouts (timeout > 0)/sect on instance _total, if counter > 0.

The response is to run a job that runs a script that will dump the current connections, their waiting status, whether they are head blocker, etc (I can build this) into a table.

Next for Options, I want to set the Delay between responses to 4 minutes.

Questions:

1) What performance issues can I anticipate?  Is there no risk, moderate risk or high risk of this alert causing performance problems in a scenario of moderate work load, high work load (100 transactions per second, a number I pulled out of my hat).

2) My second question I think that I can test.  But off the top of your head, does an ADO.Net command cause a timeout that this alert can listen to.

 


Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

transaction log greyed under tasks

$
0
0

the databases were stuck in recovery, I did restore database with recovery, and then took it offline then back it is out of restoring status but the restore status for transaction log is greyed this server is a secondary server to our primary, is there anyway i can fix this, and in the future see if the transactions are taking affect?

should note its sql server 2008 r2

Getting detailed info from OS directories?

$
0
0

Hi all of you,

I'd need to get the most detailed info for one or more directories in my local machine from SSMS/SQLCMD scenarios.

In this case I need to exclude these ones:

-PowerShell

-Stored procedures created from managed code, i.e .NET

Info gathered would encompass field data such as 'Created', 'Read-only', 'owner', 'size', 'size on disk', and so on

Up to the moment I know a couple of different ways, totally insufficient for this goal

xp_cmdshell
xp_dirtree

declare   @directory table
(
sInfo  nvarchar(MAX)
)
insert into @directory(sInfo)
exec dbo.xp_cmdshell 'dir c:\puesto\*.*';

select * from @directori
declare @directory nvarchar(255)
set @directory = 'C:\puesto\'

exec xp_dirtree @directory,3,1

Thanks for any input/hint on that,

SMSS New -> View very slow on first time

$
0
0

In SMSS on our SQL Server 2014 (12.0.4213.0) there are some maddening delays when we perform one particular function. When we right-click on View and choose New -> View. It can take from 30 to 60 seconds. Interestingly enough, when the new view comes up and we close it and create a new view immediately, it's fairly fast. It's down to about 3-4 seconds then. There's something that's happening at the first attempt but not subsequent attempts.

The delays don't seem to happen on our old SQL 2008 R2 server (10.50.6220). When we click New -> View to create a new view we always have the new view dialog box (Add Table) within 2 seconds.

Our new server is a screaming Dell PE 730 filled with SSDs and the DBs themselves between 20 and 400 GB with no more than 20 users for any of these servers. Nothing else seems to tax the server. Running applications are screaming fast.

The New -> Views function seems to be the one thing. I would love some way to  I need to tune/fix this to keep the primary DB manager happy with this server.


Datatypes and features missing in sql server 2012

$
0
0

Dear Sir/madam,

I have install sql sever management studio 2012 express edition at the time database engine dont work.

I have install sql server 2005 at the time sql server 2012 server engine is detect but i have use only sql server 2005 date type and features in sql server 2012.

how to get full features of sql server 2012 express?

i need urgent solution for this problem

Thanks & regards,

Prakash Kandhasamy

prakashknindia@hotmail.com

prakashmca20@gmail.com

At row or page level?

$
0
0

Hi all of you,

Under what circumstances can you apply compression at row or page level?

is it tight on how is built the schema of the table?

is it about to the number of rows?

using some ntext columns would require apply at row level?

What does happen if your table is partitioned?

At row level only suitable for clustered table?

I understand if you have a HEAP table best strategy would be compression at page level because when you look data you are using Table Full Scan, "visiting" all the pages allocated.

If you have one balanced tree witn non-clustered indexes

Sorry for be a pain with that, the book I am currently using (70-461) does not give info about that and it's of paramount importance in huge OLTP scenarios.

I've tested this table with a couple of million rows and the Compression Wizard suggested meat page level

This table is a balanced tree



Cannot shrink log file because all logical log files are in use

$
0
0

SQL 2005 9.0.2153 EE English
Database has recovery model = Full

I have job which is executed at night time. It executes these main tasks (in order of execution)
1. Renames transaction log backup of previous day.
2. Executes maintenance plan (check database -> rebuild indexes -> update statistics)
3. Makes fake backup of transaction log (to remove it later).
4. Shrinks log (dbcc shrinkfile(...,0, TRUNCATEONLY).
5. Deletes fake backup from step 3.
6. Makes full backup of database.

There is another job that executes every 15 minute at work time which backups transaction log.

Step 4 finishes with message "Cannot shrink log file ... because all logical log files are in use". And log size remains unchanged.

If I try to shrink log at work time using same dbcc shrinkfile I don't get message and log becomes small.

I added 2 steps with checkpointing. Now job executes these steps:

1. Renames transaction log backup of previous day.
2. Executes maintenance plan (check database -> rebuild indexes -> update statistics)
3. Checkpoints database
4. Makes fake backup of transaction log (to remove it later).
5. Checkpoints database
6. Shrinks log (dbcc shrinkfile(...,0, TRUNCATEONLY).
7. Deletes fake backup from step 3.
8. Makes full backup of database.

But message occures yet and log is not shrinked.
What I need to do to shrink log automatically. I need to shrink it because it grows very much after maintenence plan.

Increasing Buffer Pool in 2012?

$
0
0

you can do it in 2012 version or is only for 2014 on?

I would like to test in my SSD storage and see gains for high-time SELECTs


Performance impact due to sleeping sessions

$
0
0

Hi,

We are running SQL Server 2008 in a clustered environment(2 node). There were 4000+ sessions found which were sleeping, Does so much of sleeping sessions impact any manner the performance of the server. 

Viewing all 15872 articles
Browse latest View live


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