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

Dynamic column support in Bulk Load

$
0
0

Hi,

Is there any solution for the following scenario in bulk insert. 

"The csv file which is going to get processed for a particular table will change its column order periodically , and sometimes some columns will be deleted and sometimes some new columns will be added . I need to map corresponding column value from csv to table when the  order changes or values deleted or new values added"

Hope you will get ?

~Selva


Full Text crawl task permanently writes huge amount of data to disk - slowing down PC

$
0
0

Hi, all!

I asked that question already in Sql Express forum.

SQL server full text crawler on my machine permanently reads/writes a lot of data without visible reason. There are no modifications to databases made at the time. And this doesn't stop for several days already.

Recently i've noticed that my PC became very unresponsible. When I looked in resource monitor's Disk Activity tab i've found that Disk Queue Length column has value of 3 to 6, wich I think is a reason why computer became slow.

Here is to snapshots for values

Logical Disk Physical Disk  Active Time (%)    Available Space (MB) Total Space (MB)  Disk Queue Length
C: D:          0                   81.48                   137 450                    476 838              2.82
....
C: D:          0                   100.00                 137 450                    476 838               6.00

The process used disk so much was sqlserver.exe. Here is numbers for disk Read/Write activity for it:

Image          PID      Read (B/sec)   Write (B/sec)  Total (B/sec)
sqlservr.exe 1568    1 627 930        2 172 101      3 800 031

I'm using Sql Server only for development and not very often at all. There are 20 small databases in the instance. Most of them has size 25 MB, some 50 MB and a few 100 MB.

I tried to find out what sql server is doing and looked in

select * from sys.dm_exec_requests order by reads+writes desc

first 35 rows of result are FT CRAWL command running in background for more than 24 hours.

Now I wonder what SQL Server can be doing? With 1 MB per second read rate it can easy read all its databases in a couple of hours not to mention writing 3MB data per second.

Any ideas where I should look to find out what is the reason for that?

Thanks.

SQL Server stopped responding suddenly....

$
0
0

Hi, 

Yesterday evening we observed very unusual behavior of one of our production server having SQL server 2008 R2 Enterprise Edition 64 Bit.

Suddenly the server stopped responding and we are even not able to run simple query like "SP_WHO2" and not able to access any other features also, then we decoded to re-start the server (not SQL service) but the server OS.

when the server re-started, to find the reason we checked the SQL error log but not able to find any good information

but just observed error message shown below :- please any one can help me out the reason for such behavior.

The error message as shown below :-

03/13/2015 07:18:43,Server,Unknown,Process 0:0:0 (0xf5c) Worker 0x00000004EA2CC1A0 appears to be non-yielding on Scheduler 6. Thread creation time: 13070693808602. Approx Thread CPU Used: kernel 0 ms<c/> user 46 ms. Process Utilization 1%. System Idle 98%. Interval: 194672 ms.
03/13/2015 07:18:38,Server,Unknown,Process 0:0:0 (0x15c4) Worker 0x000000036047A1A0 appears to be non-yielding on Scheduler 4. Thread creation time: 13070575919131. Approx Thread CPU Used: kernel 0 ms<c/> user 46 ms. Process Utilization 1%. System Idle 98%. Interval: 194659 ms.
03/13/2015 07:17:53,Server,Unknown,Process 0:0:0 (0xc44) Worker 0x000000029DE701A0 appears to be non-yielding on Scheduler 7. Thread creation time: 13070649709109. Approx Thread CPU Used: kernel 0 ms<c/> user 0 ms. Process Utilization 2%. System Idle 96%. Interval: 70043 ms.
03/13/2015 07:17:43,Server,Unknown,Process 0:0:0 (0xf5c) Worker 0x00000004EA2CC1A0 appears to be non-yielding on Scheduler 6. Thread creation time: 13070693808602. Approx Thread CPU Used: kernel 0 ms<c/> user 46 ms. Process Utilization 1%. System Idle 97%. Interval: 134602 ms.
03/13/2015 07:17:38,Server,Unknown,Process 0:0:0 (0x15c4) Worker 0x000000036047A1A0 appears to be non-yielding on Scheduler 4. Thread creation time: 13070575919131. Approx Thread CPU Used: kernel 0 ms<c/> user 15 ms. Process Utilization 1%. System Idle 97%. Interval: 134602 ms.
03/13/2015 07:16:43,Server,Unknown,Process 0:0:0 (0xf5c) Worker 0x00000004EA2CC1A0 appears to be non-yielding on Scheduler 6. Thread creation time: 13070693808602. Approx Thread CPU Used: kernel 0 ms<c/> user 15 ms. Process Utilization 0%. System Idle 98%. Interval: 74557 ms.
03/13/2015 07:16:38,Server,Unknown,Process 0:0:0 (0x15c4) Worker 0x000000036047A1A0 appears to be non-yielding on Scheduler 4. Thread creation time: 13070575919131. Approx Thread CPU Used: kernel 0 ms<c/> user 15 ms. Process Utilization 0%. System Idle 98%. Interval: 72163 ms.
03/13/2015 07:16:38,Server,Unknown,External dump process return code 0x20000001.<nl/>External dump process returned no errors.
03/13/2015 07:16:36,Server,Unknown,Stack Signature for the dump is 0x00000000000002D4
03/13/2015 07:16:36,Server,Unknown,* *******************************************************************************
03/13/2015 07:16:36,Server,Unknown,*
03/13/2015 07:16:36,Server,Unknown,* Non-yielding Scheduler
03/13/2015 07:16:36,Server,Unknown,*
03/13/2015 07:16:36,Server,Unknown,*   03/13/15 07:16:36 spid 1588
03/13/2015 07:16:36,Server,Unknown,* BEGIN STACK DUMP:
03/13/2015 07:16:36,Server,Unknown,*
03/13/2015 07:16:36,Server,Unknown,* *******************************************************************************
03/13/2015 07:16:36,Server,Unknown,***Unable to get thread context for spid 0
03/13/2015 07:16:36,Server,Unknown,Using 'dbghelp.dll' version '4.0.5'

Please help me out.

Thanks in advance.

Regards.

Cannot upgrade database

$
0
0

Hi,

I get an error (... version (539) is not supported by this version of sql server...) when attaching an 539 version (mdf file) with SQL Server 2012 (11.0.3000) .

It's clear that this mdf file version is not supported but, is there any way to open the file despite the versions problem?

Thanks in advance.

Regards.

Replace sql job definition without changing the schedule

$
0
0

Hello,

I need to prepare a script to check if a job exists and if it does then it should replace just the job definition (steps), and keep the current state and schedule(s)

Any ideas ?

Thanks


Javier Villegas | @javier_villhttp://sql-javier-villegas.blogspot.com/

Please click "Propose As Answer" if a post solves your problem or "Vote As Helpful" if a post has been useful to you

How to efficiently support "Like"-masked range queries against a CLR UserDefinedType

$
0
0

Hi all,

Is there any way to efficiently support "Like"-masked range queries against a CLR UserDefinedType?   I've never written a UDT before and am just beginning with one that has a Varbinary type as the underlying physical type for persistence but has a string representation to the consumer.   Looking at the articles and samples I've found, the only required method/interface for a UDT that seems to be made for queries is the requirement to provide an implementation of IComparable.   

But from what I've read so far, doing a "Like" masked/range search - or any search for other than an exact "key" expression match would amount to doing a table scan while the database engine passes in each candidate to the UDT's IComparable implementation.

I need to support masked searches; including some that might wild-card the first few characters instead of always providing always providing non-wild-carded characters staring in character position one of the mask.   My UDT would have its internal structures that could vastly speed up the searches if I could get the whole Like() mask at once vs. having my IComparable methods being called once per every existing row in the underling table.    (We may have one such table with a column of this UDT containing over 800M rows.   You can imagine the response times if every search other than a single exact key match effectively meant a table scan).

I had heard that you could implement a "Like()" method in a UDT that might allow this type of processing.   But I can't find any discussions or documentation on this issue; so I'm not sure if that's really an option for solving this issue.

Thanks!
-Bob

ActiveWorkbook.Connections(Connection).OLEDBConnection -> Subscript out of range error

$
0
0

With ActiveWorkbook.Connections(Connection).OLEDBConnection  ' This statement is giving me a script out of range error                                                                                                          ' when used inside the function shown below.

Sub getData(qArray() As String, Connection As String, ActSheet As String)

'Updates the data from the Database. qArray is the SQL query in an array, connection defines which connection to use and ActSheet defines in which sheet to place the data

Sheets(ActSheet).Select
    Range("A1").Select
        With ActiveWorkbook.Connections(Connection).OLEDBConnection

        .CommandText = qArray
        .BackgroundQuery = False ' Hvis true opdateres ikke før script er kørt færdig

        .CommandType = xlCmdSql
        .Connection = "OLEDB;Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=RDWEB;Data Source=dk0149sql.niladv.org;"
        .RefreshOnFileOpen = False
        .SavePassword = False
        .SourceConnectionFile = ""
        .SourceDataFile = ""
        .ServerCredentialsMethod = xlCredentialsMethodIntegrated
        .AlwaysUseConnectionFile = False
    End With
    ActiveWorkbook.Connections(Connection).Refresh

End Sub

I am getting a subscript out of range when I use the above statement inside the  getData function shown below.

The data is getting into the qArray as seen the Locals Window after it errors

How do I eliminate this error? 

Is "lost update" possible in SQL Server?

$
0
0

hi all,

is "lost update" possible in SQL Server? if so, under what isolation level? i am just having difficulty understanding SQL Server would allow lost updates.

is there a way i can produce this issue?

please advise.



Change due to migration

$
0
0
Hi,
We currently have DTS running on Sql Server 2005. Since we will soon migrate the existing DB to Sql server 2008 R2, can we still use DTS on SS 2008, or must we use SSIS instead?

Many Thanks & Best Regards, Hua Min

Need guidance to prevent database corruption

$
0
0
I have developed a software using C# (.Net 4.0) and SQLExpress 2008 Edition. The problem I am facing is that the database is corrupted too frequently. I need guidance why the database is corrupted and How it can be prevented from corruption. There are three scenarios of corruption:
  • Case 1: Database is corrupted with following error or similar: Error: 9003, Severity: 20, State: 9. The log scan number (180:371:2) passed to log scan in database 'MyDatabase' is not valid. This error may indicate data corruption or that the log file (.ldf) does not match the data file (.mdf). If this error occurred during replication, re-create the publication. Otherwise, restore from backup if the problem results in a failure during startup. This type of corruption can be repaired and data is recovered. In most case, the similar corruption occurred.
  • Case 2: One of the system database like master or tempdb is corrupted with error similar to above error. In this case the sql service is stopped. I need to replace the files of system databases. Sometime the sql service is started and sometimes it do not. Then I have to re-install the SQLExpress server. This problem is rarely occured.
  • Case 3: Database is corrupted with following error: Error: 824, Severity: 24, State: 2. SQL Server detected a logical consistency-based I/O error: incorrect checksum (expected: 0xb956dcc; actual: 0xb956d68). It occurred during a read of page (1:337) in database ID 5 at offset 0x000000002a2000 in file '[MDF File Path]'.  Additional messages in the SQL Server error log or system event log may provide more detail. This is a severe error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online. DBCC CHECKDB ([MyDatabase]) WITH all_errormsgs, no_infomsgs executed by d-PC\d terminated abnormally due to error state 5. Elapsed time: 0 hours 0 minutes 1 seconds. Setting database option AUTO_CLOSE to OFF for database MyDatabase. This type of corruption can not be repaired and data is not recovered. This type of corruption is most rare.
I need guidance why these situations arise and how can these situations be prevented so that I can add preventive measures in software.

How many times does a SQL job run if it is set to run twice a day and it takes 13 hours for the job to run each time?

$
0
0

Hi,

I have a SQL job set to run twice a day. However, the time taken for the job to run each time is 13 hours. In such a case, can you please let me know the number of times the job will run?

Thanks in advance for the reply!!

Database maintenance plan with Always on

$
0
0

Hi,

I have set-up SQL Always on availability for our our new system database environment. I am not sure what should be the database maintenance plan for this environment as I think we already have a real time copy of database on replica's? Does any issue with primary database data files effects replica?

On our existing environment, I take regular backups consisting of Full, Differential and Transaction logs. 

Thanks in advance.


Shady

Some update lock issues

$
0
0

Can you kindly give me some examples such as:

1, when the page needs the U lock?

2, When the table needs the U lock?

3,When the table\page need the UIX ?

It's better if you can provide the T-SQL Script to prove it, Thak you inAdvanced.



Please click the Mark as Answer button if a post solves your problem!

Storage layout (Hyber-V and SQL 2012)

$
0
0

Hi,

I have SQL 2012 virtualized Hyper-V and was looking for the best practice for storage layout , is it the same layout ususely using for physical SQL Server.

This SQL instance will be the backend for MS-TFS 2013

what the means Mode '0-null'

$
0
0

I run the  T-SQL below , and saw 0-null ,what the means? why SQL need them?

update  [dbo].[Table_1] set C2='44'  where [C1]='A4'



Please click the Mark as Answer button if a post solves your problem!



Windows Server Failover Clustering (WSFC)

$
0
0

Can I add notes to a Windows Server Failover Clustering (WSFC) with different operating systems? For instance, one node is Windows 2008 R2, and other nodes is Windows 2012.

Thanks,

Lijun

After mapping login to user its not Reflecting.

$
0
0
Hi Experts,i have a scenario that i have created the one login 'ABC' and mapped to all dbs in server with Read write permittions,But when i check with ABC login i am not able to see the mapped databases, i can see only master and temp db,it was reflecting only when i give sys admin privileges.can any one help me out in this.

Statistics and Cardinality Estimation

$
0
0

Hi,

1) In some circumstances , while statistics are up to date we still see difference between Estimated number of records and the Actual one in an execution plan.

Why this difference exists?  

2) When Database engine follows the linked list of the leaf pages in index key order of a Clustered Index, we see ordered property of Clustered Index Operator is True. Does it mean that the order of result will be guaranteed? Can we say that because of page splits that are are occurred in leaf level of index, the Result will not be sorted (because pages are not adjacent and thus they are just logically ordered and therefore physical scan of the leaf level will not get sorted result).

Thanks.


Script to change Collation settings on specific objects and columns on existing db

$
0
0

I am getting error when I tried to alter collation on some specific tables. 

ALTER TABLE [abcd] ALTER COLUMN [abc] varchar(255) COLLATE SQL_Latin1_General_CP1_CS_AS NULL

Msg 5074, Level 16, State 1, Line 13
The index 'l_abc_idx' is dependent on column 'abc'.
Msg 4922, Level 16, State 9, Line 13

ALTER TABLE ALTER COLUMN OWNER failed because one or more objects access this column.

I am looking for method to change any inputs?

Thanks,

Sree


Sree

Auto update stats disabled for a user Database in Sql server

$
0
0

While trying to improve the performance of few queries, we found via execution plan that there were lot of Index/Clustered index seeks. Therefore:

First thing we did, was to check our Re-indexing and update stats job which runs weekly for this user DB ( Around 400 GB in size and is used 24*5). The job was running fine.

Later when we ran SP_Blitz, we came to know that auto-update-stats is disabled for this user DB. We expected this to be a possible cause and change it from false to TRUE(Auto update stats)

Also, per SP_blitz there are user-created statistics for this DB. When ran the query to check how many, we saw around 7K user stats out there.

So my question would be 1) setting the Auto update stats to TRUE would require a reboot or once changed i need to track the performance and 2) Should we consider dropping those user created stats or manually look into them one by one.

How should we proceed on this, please suggest, thanks!

Viewing all 15889 articles
Browse latest View live


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