Quantcast
Channel: Fórum SQL Server Database Engine
Viewing all 15680 articles
Browse latest View live

SP_RELEASESCHEMALOCK, SP_GETSCHEMALOCK, SP_UNPREPARE

$
0
0

I've been doing some tracing on one of our production systems and I'm seeing some system stored procedures being called I've never seen before. Here are the series of events:

Code Snippet

declare @p1 int
set @p1=1
declare @p2 bigint
set @p2=169603968398352
exec [sys].sp_getschemalock @p1 output,@p2 output,N'"ClinicAdmin"."dbo"."EMR_VIEW_Clinic"'
select @p1, @p2

 

 

So I'm assuming this chunk of code is obtaining a schema lock on EMR_VIEW_Clinic. Next is:

Code Snippet

declare @p1 int
set @p1=4725
exec sp_prepexec @p1 output,N'@P1 int',N'SELECT "Tbl1002"."CLINIC_ID" "Col1004","Tbl1002"."CLINIC_HOST_ID" "Col1005","Tbl1002"."CLINIC_HostNumber" "Col1006","Tbl1002"."CLINIC_REG_ID" "Col1007","Tbl1002"."CLINIC_CLINICTYPE_ID" "Col1008","Tbl1002"."CLINIC_PRICEGEO_ID" "Col1009","Tbl1002"."CLINIC_Address_COUNTRY_ID" "Col1010","Tbl1002"."CLINIC_AddressStreet1" "Col1011","Tbl1002"."CLINIC_AddressStreet2" "Col1012","Tbl1002"."CLINIC_AddressCity" "Col1013","Tbl1002"."CLINIC_AddressStateProvince" "Col1014","Tbl1002"."CLINIC_AddressPostalCode" "Col1015","Tbl1002"."CLINIC_Name" "Col1016","Tbl1002"."CLINIC_ShortName" "Col1017","Tbl1002"."CLINIC_FolderName" "Col1018","Tbl1002"."CLINIC_Active" "Col1019","Tbl1002"."CLINIC_PseudoClinic" "Col1020","Tbl1002"."CLINIC_IPAddress" "Col1021","Tbl1002"."CLINIC_GLRegion" "Col1022","Tbl1002"."CLINIC_GLCity" "Col1023","Tbl1002"."CLINIC_GLClinic" "Col1024","Tbl1002"."CLINIC_GLTypeOfClinic" "Col1025","Tbl1002"."CLINIC_CLIA_Number" "Col1026","Tbl1002"."CLINIC_FirstOpenDate" "Col1027","Tbl1002"."CLINIC_LastOpenDate" "Col1028","Tbl1002"."CLINIC_Subsidized" "Col1029","Tbl1002"."CLINIC_NumberOfExamRooms" "Col1030","Tbl1002"."CLINIC_Phone_COUNTRY_ID" "Col1031","Tbl1002"."CLINIC_PhoneNumber" "Col1032","Tbl1002"."CLINIC_PhoneExt" "Col1033","Tbl1002"."CLINIC_CVSCostCenter" "Col1034","Tbl1002"."CLINIC_NoPayer_LABPROC_ID" "Col1035","Tbl1002"."CLINIC_Payer_LABPROC_ID" "Col1036","Tbl1002"."CLINIC_AllowEPrescribing" "Col1037","Tbl1002"."CLINIC_EnablePortalEnrollment" "Col1038","Tbl1002"."CLINIC_EnablePCPFaxing" "Col1039","Tbl1002"."CLINIC_QuickCode" "Col1040" FROM "ClinicAdmin"."dbo"."EMR_VIEW_Clinic" "Tbl1002" WHERE "Tbl1002"."CLINIC_ID"=@P1',759
select @p1

 

 

 I have no idea what sp_prepexec does, but it looks like it's executing that big query. The last two are:

Code Snippet

 

exec sp_unprepare 4725

 

exec [sys].sp_releaseschemalock 1

 

 

The one thing about that last one - sp_releaseschemalock - the number on the end will vary between 1 through 4. In my readings, I've surmised that when you see this kind of activity, it's not good.

 

If anyone could shed some light on this that would be awesome!!

 

Thanks!

 


100 % CPU Utilization by SQL server 2008 r2 express edition

$
0
0

Dear all,

Can any one please help me to find the root cause of  the issue.
Our production server is running on sql server 2008 R2 express edition.( its running on Virtual machine Windows 2008 ).
Its not consuming  100 % CPU all the time, however  some times its reaches on 90% above  CPU utilization and stays there for 2 to 3 hours, this is happening quite frequently in a day.
Our community website is running over the sql server, i never noticed any performance issue while browsing the website during high CPU usage as well.

Regards,

Itishree

SQL Server Express Backup Import.

$
0
0

Hi All,

I've written a batch script to automatically import the latest backup from another server. Both are running the same version of SQL Exptress 2008. If I run the script via the command prompt it works but if I run it via scheduled jobs it fails with the following error:

Msg 3201, Level 16, State 2, Server GSP-UKBS-SNMP02\WHATSUP, Line 1
Cannot open backup device 'D:\WUGData\backups\'. Operating system error 3(The system cannot find the path specified.).
Msg 3013, Level 16, State 1, Server GSP-UKBS-SNMP02\WHATSUP, Line 1
RESTORE DATABASE is terminating abnormally.

The script I've written is(please be gentle this is my 3rd batch script):

@echo off

FOR %%A IN (%Date:/=%) DO SET Today=%%A

echo. | date | FIND "(mm" > NUL
  If errorlevel 1,(call :Parsedate DD MM) Else,(call :Parsedate MM DD)
  goto :EOF
 :Parsedate ----------------------------------------------------------
  For /F "tokens=1-4 delims=/.- " %%A in ('date /T') do if %%D!==! (
     set %1=%%A&set %2=%%B&set YYYY=%%C
   ) else (
     set DOW=%%A&set %1=%%B&set %2=%%C&set YYYY=%%D)

(Set DateStamp=%YYYY%%MM%%DD%)

echo today datestamp is: %DateStamp% >> D:\WUGData\backups\logs\%DateStamp%_log.txt

:CHKFILE
IF EXIST "D:\WUGData\backups\NFArchive_Full_%DateStamp%.bak" (

SET NetFlow=Netflow_Full_%DateStamp%.bak
SET NFArchive=NFArchive_Full_%DateStamp%.bak
SET WhatsUp=WHatsUp_Full_%DateStamp%.bak

echo %DATE% %TIME% - Start Netflow SQL Import >> D:\WUGData\backups\logs\%DateStamp%_log.txt
SqlCmd -E -S GSP-UKBS-SNMP02\WHATSUP -d master -Q "RESTORE DATABASE [Netflow] FROM DISK='D:\WUGData\backups\%NetFlow%' WITH RECOVERY, REPLACE, MOVE 'Netflow' TO N'D:\Program Files\Microsoft SQL Server\MSSQL10_50.WHATSUP\MSSQL\DATA\Netflow.mdf', MOVE 'Netflow_log' TO N'D:\Program Files\Microsoft SQL Server\MSSQL10_50.WHATSUP\MSSQL\DATA\Netflow.ldf', STATS = 10" >> D:\WUGData\backups\logs\%DateStamp%_log.txt
echo %DATE% %TIME% - Completed Netflow SQL Import >> D:\WUGData\backups\logs\%DateStamp%_log.txt

echo %DATE% %TIME% - Start NFArchive SQL Import >> D:\WUGData\backups\logs\%DateStamp%_log.txt
SqlCmd -E -S GSP-UKBS-SNMP02\WHATSUP -d master -Q "RESTORE DATABASE [NFArchive] FROM DISK='D:\WUGData\backups\%NFArchive%' WITH RECOVERY, REPLACE, MOVE 'NFArchive' TO N'D:\Program Files\Microsoft SQL Server\MSSQL10_50.WHATSUP\MSSQL\DATA\NFArchive.mdf', MOVE 'NFArchive_log' TO N'D:\Program Files\Microsoft SQL Server\MSSQL10_50.WHATSUP\MSSQL\DATA\NFArchive.ldf', STATS = 10" >> D:\WUGData\backups\logs\%DateStamp%_log.txt
echo %DATE% %TIME% - Completed NFArchive SQL Import >> D:\WUGData\backups\logs\%DateStamp%_log.txt

echo %DATE% %TIME% - Start WhatsUp SQL Import >> D:\WUGData\backups\logs\%DateStamp%_log.txt
SqlCmd -E -S GSP-UKBS-SNMP02\WHATSUP -d master -Q "RESTORE DATABASE [WhatsUp] FROM DISK='D:\WUGData\backups\%WhatsUp%' WITH RECOVERY, REPLACE, MOVE 'WhatsUp' TO N'D:\Program Files\Microsoft SQL Server\MSSQL10_50.WHATSUP\MSSQL\DATA\WhatsUp.mdf', MOVE 'WhatsUp_log' TO N'D:\Program Files\Microsoft SQL Server\MSSQL10_50.WHATSUP\MSSQL\DATA\WhatsUp.ldf', STATS = 10" >> D:\WUGData\backups\logs\%DateStamp%_log.txt
echo %DATE% %TIME% - Completed WhatsUp SQL Import >> D:\WUGData\backups\logs\%DateStamp%_log.txt

echo %DATE% %TIME% - SQL Import complete >> D:\WUGData\backups\logs\%DateStamp%_log.txt

) ELSE (

echo %DATE% %TIME% - Backup not ready for import, waiting 30min before retry. >> D:\WUGData\backups\logs\%DateStamp%_log.txt

TIMEOUT /T 10 /NOBREAK
GOTO CHKFILE

)

Any help would be much appreciated.

Transfer users from SQL to Windows Authentication

$
0
0

I woulld like to transfer current sql authentication users to Windows authentication, without loosing their respective grants to roles. Can anyone help.

Thanks

Msg 3013, Level 16, State 1, Line 1

$
0
0

Hi,

I have sql server 2008 enterprise edition.

My log file is showing about to full the HDD and the database is in logshipping but it is paused due to some customer requirement.

I want to shrink the log file of source server because on restoring full backup on destination server asking the same space as source server.

I have used the:

Backup log dbname to disk='NULL';

but after completing 20% it is giving error:

Msg 3202, Level 16, State 1, Line 1
Write on "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Backup\NULL" failed: 112(There is not enough space on the disk.)
Msg 3013, Level 16, State 1, Line 1
BACKUP LOG is terminating abnormally.

While c:\ drive has 30 GB free.


Thanks

I am running the job getting below error while on changing job owner to first account job is working

$
0
0

I have two sa accounts on sql server 2008 R2:

1. xyz-NDC-SDB2-U\Administrator
2. xyz-NDC-SDB2-U\UATDBADMIN

From second account a new job is created and sql server service is running from first account.

When I am running the job getting below error while on changing job owner to first account job is working:

Error code 0x5. [SQLSTATE 42000] (Error 15404): Could not obtain information about Windows NT group/user MyDomain\MyUserName'

I want to run my job using second account.


Thanks

Backup has failed in sql server 2005

$
0
0

Hello,

Today my sql server 2005 backup job has been failed with the following error:

Executing the query "BACKUP DATABASE [XXXXXXX] TO  DISK = N'\\\\servername\\XXXx\\xyz\\xxxxxxxxx_backup_201211150300.bak' WITH NOFORMAT, NOINIT, NAME = N'xxxxxxxxx_backup_20121115030010', SKIP, REWIND, NOUNLOAD, STATS = 10

" failed with the following error: "Write on "\\\\servername\\XXXx\\xyz\\xxxxxxxxx_backup_201211150300.bak" failed: 1398(There is a time and/or date difference between the client and server.)

may i know what is error


Maheshwar Reddy

Copy mdf and ldf file to other storage without offline database

$
0
0

We're sql 2005 enterprise with sp2 and want to copy our user database mdf and ldf files to other storage since the full backup job failed for unknown reason. But seems we need to offline db or shutdown sql service so as to copy these files successfully. Is there any other way to copy successfully without offine the db or shutdown sql service?

We already glanced through event log, sql server log and sql agent job history and there's no any error code or descriptions to state out the fail reasons for full backup job, any suggestions to view or turn on more error descriptive messages?

Thx a lot

Best regards,
Wallace



CDC database corrupt

$
0
0

Help,

our CDC enabled database is corrupted on a systemobject, updates are still working fine, but no BU can be taken due to a checksum error during checkpoint.

We copied all user data into a newly restored version of the DB (keep CDC) but what do we need do do next for the CDC to work correctly using the new database. The new DB needs to get the name of the original DB, but we hesitate to rename the original because of the corruption issue.

Can somebody direct us to a kind of action plan we need to follow? Many thanks


Geert Vanhove DCOD ------ http://geertvanhove.wordpress.com/ ----------- Please click the Mark as Answer or Vote As Helpful if a post solves your problem or is helpful!

How to configure jobs and to notify to the user in SQL SERVER 2008 servers

$
0
0

Hello,

I have 20 SQL 2008 servers we dont have any monitoring tool to monitor for job failures,low disk space,log file is full,database is offline or suspect

mode etc.

Could any please help me how to configure those alerts and to notify to our mails.


Maheshwar Reddy

System.OutOfMemoryException running Activity Monitor when total sql processes become very large

$
0
0

Hello,

I am using Sql Server 2012. I get the following exception when the total sql processes become very large (in excess of 100,000) and I open Activity Monitor.

Exception:

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

The Activity Monitor is unable to execute queries against server xxxxxx.
Activity Monitor for this instance will be placed into a paused state.
Use the context menu in the overview pane to resume the Activity Monitor.

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

Exception of type 'System.OutOfMemoryException' was thrown. (mscorlib)

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

   at System.String.CreateStringFromEncoding(Byte* bytes, Int32 byteLength, Encoding encoding)
   at System.Text.UnicodeEncoding.GetString(Byte[] bytes, Int32 index, Int32 count)
   at System.Data.SqlClient.TdsParserStateObject.ReadString(Int32 length)
   at System.Data.SqlClient.TdsParser.ReadSqlStringValue(SqlBuffer value, Byte type, Int32 length, Encoding encoding, Boolean isPlp, TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.ReadSqlValue(SqlBuffer value, SqlMetaDataPriv md, Int32 length, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlDataReader.ReadColumnData()
   at System.Data.SqlClient.SqlDataReader.ReadColumn(Int32 i, Boolean setTimeout)
   at System.Data.SqlClient.SqlDataReader.GetValueInternal(Int32 i)
   at System.Data.SqlClient.SqlDataReader.GetValues(Object[] values)
   at System.Data.ProviderBase.DataReaderContainer.CommonLanguageSubsetDataReader.GetValues(Object[] values)
   at System.Data.ProviderBase.SchemaMapping.LoadDataRow()
   at System.Data.Common.DataAdapter.FillLoadDataRow(SchemaMapping mapping)
   at System.Data.Common.DataAdapter.FillFromReader(DataSet dataset, DataTable datatable, String srcTable, DataReaderContainer dataReader, Int32 startRecord, Int32 maxRecords, DataColumn parentChapterColumn, Object parentChapterValue)
   at System.Data.Common.DataAdapter.Fill(DataSet dataSet, String srcTable, IDataReader dataReader, Int32 startRecord, Int32 maxRecords)
   at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
   at Microsoft.SqlServer.Management.ResourceMonitoring.BackgroundQueryTask.Execute()
   at Microsoft.SqlServer.Management.ResourceMonitoring.BackgroundWorkRequest.Execute()
   at Microsoft.SqlServer.Management.ResourceMonitoring.BackgroundWorkRequestQueue.BackgroundWorker_DoWork(Object sender, DoWorkEventArgs e)
   at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
   at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)

SQL Version: 

Microsoft SQL Server 2012 - 11.0.2325.0 (X64)
 Jun  8 2012 18:54:43
 Copyright (c) Microsoft Corporation
 Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)

What additional information would be needed to work on this????

Moving SQL 2008 R2 database

$
0
0

one of my database is inaccessible as the Drive space got full. I couldn't add extra disk space on that drive.

Shall i make offline and then detach --> copy and then attach.

The above approach will work or create any problems

Thanks

Rocky

So many LATCH_EX

$
0
0

Hi all

I select

select * from sys.dm_os_latch_stats
to check wait type, and find many

ACCESS_METHODS_DATASET_PARENT
what's it actually doing? and it cost so many CPU resourcese.

SQL Server - Which one do I need

$
0
0

Hello All,

I have install Visual Studio Professional 2012.  I will develop a application that will use SQL Tables on the PC only, NOT on the web.

Questions:

(1)  What SQL Server should I down purchase/down load/Install?

(2)  When I implement the application on another PC will the other PC have to have SQL Server installed on it  or will my application have everything it need?

(3)  What LINK do I used to purchase the SQL Server from question 1 above?

Ed.


ecb

SQL AGENT JOB - Manually runnable only

$
0
0

Hello,

  I have this sql server agent job in sql server 2008 that runs every month.
  I want to make this job manually runnable only - basically remove the recursive schedule.
  How do I achieve this using TSQL?

Thanks! 


How to get sql server editon assuming the sql server service is not running?

$
0
0

Hi all,

I can find the sql server version info by checking the sqlserver.exe file

But I cannot get the Edition information anywhere unless I can log into the server and do select ServerProperty("Edition"). However if the sql server service is offline, I cannot get this Edition information.

Could anyone please help out here? or there is no way I can do this at all?

Eventlog grows constantly with repeating message: Starting up database 'AdventureWorks2012'.

$
0
0

I'm not sure what I have done wrong!

I installed the latest SQL SERVER 2012 Expression (with Advanced Services) (SP1). Then I downloaded the sample Adventueworks sample database from codeplex. I copied the MDF to

C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA and attached it.

Now a weird problem occurs - my Eventlog grows constantly with never-stopping messages like this:

Starting up database 'AdventureWorks2012'.

There are no error or even warning messages about SQL SERVER. I can use Management Studio to do query and all functions seem work fine.


Matrix is real.

Unable to connect to SQL Server '(local)'. The step failed.

$
0
0

Hi

i am getting below error , in sql Agent 2008(R2) RTM  one of my  job. if i run manually  it getting succeed. But in job only some time it is getting failed , please help me  

note: this job is pointing to Remote Server  

Unable to connect to SQL Server '(local)'.  The step failed.

Regards,

venkat


regards venkat

SQL installation Path

$
0
0

Hi ALL I have a MSSQL2005 cluster

I would like to the installation path from one drive to another. How can I do that ?

How to estimate log growth when providing DML

$
0
0

Hi there,

what is the way how to estimate log growth when providing UPDATE, INSERT,DELETE on table?

I have tested growth on test table which has 25 milion rows of 4 columns, each type int. Whole table has storage size 390 MB. There is no index on the table. My log file has 2 MB and is almost empty. My DB is in simple mode.

When I update one value for all rows

UPDATE TABLE
SET col1 = col1 + 10

then my log is going to 10000+ MB of allocated space and 8000+MB of used space. How it works? What happened that log went to 10000 of MBs? Then he evidentally released 8000 MB of log data. Could you please explain in detail what is happening when DML is done ?

Then I repeated test with full recovery option on DB and result is same like in simple flow.

For me its strange, that it is not enough to store original data in log table I am trying to update. (390 MB)

Thanks for help

Viewing all 15680 articles
Browse latest View live


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