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

Transactional log backup script error

$
0
0

We are getting the error as below:

Message
Executed as user: domain\DBAdmin. sqlmaint.exe failed. [SQLSTATE 42000] (Error 22029).  The step failed.

The transactional logs are not deleting since Sept 2019. What is the best process of deleting the transactional logs? Can I create full backup, change the database recovery mode to simple, delete all transactional logs and run the job again.


SQLServer 2016 - PolyBase - Exporting Data

$
0
0

All,

In PolyBase, can t we append data into the External Table (csv file as the source) with rows from T-SQL?

The below example seems to indicate so:

https://docs.microsoft.com/en-us/sql/relational-databases/polybase/polybase-configure-azure-blob-storage?view=sql-server-ver15#exporting-data

If this is true, then for every source that we need to append to should we also create another EXTERNAL table? The INSERT seems to be work on the newly created table.

Thanks,

rgn

Where can I find prepared SQL statements (sp_prepare) in the system tables/views?

$
0
0

Environment: SQL Server 2014 on Windows Server 2012 R2.

Our application uses hibernate and the jTDS JDBC driver, so we are (by default) getting generated SQL statements coming through as sp_prepare and sp_execute.  Sometimes, I am able to find the prepared queries in the cache, but sometimes I'm not.  By cache, I mean sys.dm_exec_query_stats and sys._dm_exec_cached_plans.  What's strange is that even if they seem to be gone from the cache, the prepared statements execute successfully.  I'm wondering if there is some other location where I could consistently see/find the prepared statements, hopefully by their integer handle?

Thank you,

-Peter

Always On availability groups VS Kubernetes Service

$
0
0
there are two different approach to create HA SQL cluster

1. Windows cluster, then sql always on availability groups,

2. Use kubernetes, such as AKS, then build ,


Which options is better or what's pro and con?


How about SQL Server 2019 big data clusters?

High Disc Latency Issue

$
0
0

Hi,

We are experiencing occasional high disc latency and high CPU utilization in the SQL Server and want to know how to check the bottlenecks.  we have a graph which describes the high disc latency and i want to know how to identify the bottlenecks from the graph.

Thanks,


SQLSever 2016 - PolyBase - Datetime data

$
0
0

All,

When I query an External Table which has a datetime column why is it giving me an error even though I was able to enter data into it successfully? This table is pointing to Azure Blob Storage.

Msg 7320, Level 16, State 110, Line 28
Cannot execute the query "Remote Query" against OLE DB provider "SQLNCLI11" for linked server "(null)". Query aborted-- the maximum reject threshold (0 rows) was reached while reading from an external source: 1 rows rejected out of total 1 rows processed.
(/claim/QID639_20200107_154411_0.txt)Column ordinal: 2, Expected data type: DATETIME, Offending value: 2010-01-06 00:00:00.000  (Column Conversion Error), Error: Conversion failed when converting the NVARCHAR value '2010-01-06 00:00:00.000' to data type DATETIME.

CREATE EXTERNAL TABLE dbo.wasbs_Claim
( 
    	ID int,
    	Claim VARCHAR(128),
        Claimdate datetime
) 
WITH 
( 
    LOCATION = '/claim/',  -- see below comment 
    DATA_SOURCE = csvsource, 
    FILE_FORMAT = csvformat
)
GO
insert into dbo.wasbs_Claim(ID,Claim,Claimdate) Values (1,'Automobile','01/06/2010') -- Will fail
GO
select * from dbo.wasbs_Claim

The below T-SQL query goes through though:

DECLARE @stringdate nvarchar(100)
SET @stringdate = '2020-01-06 00:00:00.000'
DECLARE @datetime datetime
SET @datetime = @stringdate
PRINT @datetime
PRINT @stringdate

dbmail alert code

$
0
0

Hi,

I am new to the SQL coding. Need help in configuring the mirroring alert when the db will go to suspect mode.

I configured dbmailprofile and succesfully i am able to send the mail through sql server .

now for alert i given the below step in job.

exec msdb.dbo.sp_send_dbmail

@profile_name='newprofile1',

@recipients='abc@xyz.com',

@query='select name,state_desc from sys.databases where state in (0,1,2,3,4,5,6)'

@subject='db status alert',

@body='status of the db'

I required the code in such a way that alert should generate when ever the database will go to suspect mode.

As of now i configured in such a way that its throwing mail with current db status.

But need mail only when db will go to suspect mode.

i configured the job schedule for every 15 min. instead of giving mail for every 15 min , i should get mail only database will go to suspect mode.

Please help me to modify the code. Its little urgent.

Thanks,

Jo


pols

The failure occurred when executing the command 'sp_cdc_create_change_table'. The error returned was 15562

$
0
0

I'm trying to enable a table for CDC and get the below error. Enabling CDC did work previously and we have added multiple tables before.
Msg 22832, Level 16, State 1, Procedure sys.sp_cdc_enable_table_internal, Line 666 [Batch Start Line 28]
Could not update the metadata that indicates table [sdm].[FLXRL_Policy] is enabled for Change Data Capture. The failure occurred when executing the command 'sp_cdc_create_change_table'. The error returned was 15562: 'The module being executed is not trusted. Either the owner of the database of the module needs to be granted authenticate permission, or the module needs to be digitally signed.'. Use the action and error to determine the cause of the failure and resubmit the request.
What I can could see was that EXEC sys.sp_cdc_enable_table is executing sys.sp_cdc_enable_table_internal and if I execute the that sp it returns
Msg 2812, Level 16, State 62, Line 26
Could not find stored procedure 'sys.sp_cdc_enable_table_internal'.
Any suggestions or guidance is appreciated


checkdb killed/rollback - stuck for 3 days

$
0
0

I have a scenarios whereby a checkdb on an 800GB database was cancelled and 3 days later, there is sessions stuck in "killed/rollback" state.

I ran 

select blocking_session_id, wait_time,wait_type, last_wait_type, open_transaction_count, percent_complete,estimated_completion_time, cpu_time,total_elapsed_time, reads, writes, granted_query_memory, parallel_worker_count
FROM SYS.DM_EXEC_REQUESTS
where session_id in (66)

and i see the wait type is EXECSYNC,  percent complete 10,05694 and doesnt change, estimated completion time is rising, cpu_time is not changing, reads and writes are not changing either.   

I dont want to restart the Instance as i am afraid the database will go into recovery and it will take the same time to recover and users will not be able to access, for now, at least users can access but it is extremely slow. 

Will it eventually complete? or its hung ?

Any advice ? 


ilikefondue

check the time of the restored database for ms sql server 2014

$
0
0

Dear,

We want to restore a ms sql database from full database backup and differential backup.

Please help to tell me how to confirm the time of restored database. Thanks!

SQL Alerts

$
0
0

I am having a requirement to send mail alerts when there is a blocking. And I am planning to use SQL alerts.

We have a counter called 'Processes Blocked'. Can it be used to capture blocking details? If so, what all information will it gather.

Also, I see an option alert is counter rises\equals to 'value'. What is the value here?

Is it the time a blocking remains or the count of blockings?

Please suggest if there are any better options.

SQL 2016 ENT Edition Database -Lock pages in memory option on VM SQL Server

$
0
0

We are almost running all our production systems in VM and almost all servers are 64 bit , currently we have an Windows Server 2012 R2 VM Server that runs with SQL2016 SP2 ENT Core based edition.

OLTP system with 32 virtual processor and 4 sockets we have 128GB RAM, now we are with vendor isolating performance issues and vendor is keen to know why we have set our SQL service account with lock pages in memory which is not an VM ware recommendation .

Since we have max server memory defined on the instance ( we use as an standard to allocate 75% to DB and 25% to OS) and on all 64 bit boxes regardless of Physical or VM we have this lock pages in memory set.

I am stressed to know if really on VM SQL Servers Lock pages in memory option should not have been set or since we have already set max server memory to 75% of servers memory we are good on this memory part or is there really an trade off so my application vendor compels to go with VM recommendation not to set LPIM 

Thanks and Reagrds

Eben

SQLServer 2019 Polybase - External access operation failed because the location URI is invalid. Revise the URI and try again.

$
0
0

All,

I tried to create an External Data Source against another SQLServer (2016) from a SQLServer 2019 server but I get the below error:

<<External access operation failed because the location URI is invalid. Revise the URI and try again.>>

NYCSQL10.nydomain.net is a SQLServer 2016 server

Configure PolyBase to access external data in SQL Server

What am I missing?

Thanks,

rgn

   CREATE EXTERNAL DATA SOURCE PolyBaseSQL
    WITH ( 
    LOCATION = 'sqlserver://NYCSQL10.nydomain.net\ACT:1488',
    -- PUSHDOWN = ON | OFF,
      CREDENTIAL = SQLServerCredentials
    );
    GO


GetDate() in SQL Server on Linux and UTC

$
0
0

Hi,

Is my understanding correct that in SQL Server on Linux we will always get UTC time when running SELECT GetDate()?

Can't find any documentation related to this at all.

Thanks

Total Server Memory VS Target Server Memory made me crazy.

$
0
0

I often see somebody use the Total Server Memory compare to Target Server Memory to decide whether the SQL Server under memory pressure. a book say:”Total and Target should be almost the same on a server with no memory pressure that has been running

 for a while. If Total is significantly less than Target, then it’s likely that SQL Server cannot grow the buffer pool due to memory pressure”;

that is to say: if Total Server Memory <Target Server Memory ,it Represents Memory Pressure .

 

but I also see a article say:”

If the SQLServer:Memory Manager: Total Server Memory (KB) counter is more or equal than the SQLServer:Memory Manager: Target Server Memory (KB) counter, this indicates that SQL Server may be under memory pressure and could use access  to more physical memory.”

http://blogs.msdn.com/b/teekamg/archive/2007/11/06/sql-server-memory-related-performance-counters.aspx 

 that is to say: if Total Server Memory >= Target Server Memory ,it Represents Memory Pressure   

 

So from those twomaterial:

if Total Server Memory <Target Server Memory ,it Represents Memory Pressure.

 if Total Server Memor>=Target Server Memory ,it still Represents Memory Pressure.

 That made me crazy,

So what's your opinion? thank you.





OPENROWSET and csv file

$
0
0

All,

The link shows how to create a format file using BCP. This assumes that the data is always extracted from a SQLServer table.

We receive lot of csv files from our business partners for which we cannot generate the format file and we plan to use them using OPENROWSET with the csv files being placed in Azure Blob Storage. Does anyone know how to generate the format file for a given csv file other than creating one manually?

In the below script, I manually created the format file currency.fmt for the csv data file currency.csv

Thanks,

rgn

 CREATE EXTERNAL DATA SOURCE pocBlobStorage
WITH (	TYPE = BLOB_STORAGE, 
		LOCATION = 'https://eventhubstore.blob.core.windows.net/datasets', 
		CREDENTIAL= sqlblob);

-- 2.4. Query remote file 
SELECT *
FROM OPENROWSET(BULK 'currency.csv',
				DATA_SOURCE = 'pocBlobStorage',
				FORMATFILE='currency.fmt',
				FIRSTROW=2,
				FORMATFILE_DATA_SOURCE = 'pocBlobStorage') as D
Inner Join [dbo].[State] C
On C.[id] = D.CurrencyKey


SQL Agent Job

$
0
0

Hi All,

How can i schedule a SQL job, which should not run on first 6 days of every month.


Vinai Kumar Gandla

restore ms sql server reportserver database error

$
0
0

Dear,

When I restore reportserver database on ms sql server, there is error[database in use].

But I checked the service, there is no reportserver service.

Please tell me how to restore this special database. Thanks!

Installing CU for SQL 2016

$
0
0

Hi,

I need suggestions from you for below requirememnt. 

we are having two production SQL Servers. 

Version: SQL 2016

Productlevel: SP1

Edition: Enterprise, Core based licensing 64 bit

Product version: 13.0.4224.16 

Productupdatelevel: null

As per the requirement now we need to install latest CU on this server.  I searched the microsoft website for latest CU. I am little confused about finding the correct latest CU to download and install. 

Can you please guide what exactly to download so production sql server will be upto date with all updates?

Actually my current production is SP1.But in Microsoft website i see already sp2 released and latest CU are there for sp2. So shall i go ahead with downloading latest CU for SP1? OR download SP2 with latest CU? 

Which one i need to install ?Please share the exact link to download. 

How to consider which one i need to install the latest CU?

Thanks

Jo


pols


Agent job failing with string or binary data truncated, proc runs successful from SSMS

$
0
0
have a monthly sql agent job that executes a stored proc and it started failing a month ago with string or binary data would be truncated error. It has been running for years with no issues, no server changes or db changes related to this process for years. I restore the database and log files to a dev machine to get back to the point in time when the failure happens and the proc runs successful from SSMS. I have dealt with these errors in the past by putting a timestamp on the table being updated to locate the row, but since the proc runs I can't seem to find what is wrong. Is it something in the agent job itself possibly? I set the agent job up on the dev machine and it runs successfully. The proc is not complex, it is doing some value calculations, I don't see anywhere a string length could exceed any of the variables. This is on a 2008 R2 standard edition server.

Any ideas would be appreciated
Viewing all 12963 articles
Browse latest View live


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