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

create unique key on Partition table

$
0
0

Need to create unique key on ref_number column in [purchase_order] table,

while use below 

CREATE UNIQUE NONCLUSTERED INDEX [idx_unique_PO] ON [dbo].[purchase_order]
(
[ref_number] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF,
 ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [psPurchase_order]([id])

getting error,

Column 'id' is partitioning column of the index 'idx_unique_PO'. Partition columns for a unique index must be a subset of the index key.

So i created Partion-key index,    this one created but this still allow duplicate


CREATE UNIQUE NONCLUSTERED INDEX [IX_Unique_purchase_order_partic] ON [purchase_order] 
(
    [ref_number] ASC,
    id
) ON [psPurchase_order](id)


Maintenance jobs failed with Integration Services evaluation period has expired ?

$
0
0

Hi All,

in this server , SSIS not at all installed and it's SQL server 2016 sp2 CU10 cluster enterprise edition and no old versions are running in this server but maintenance jobs are failing with below error....

Error Details:
Source: Full_Backup      Description: Integration Services evaluation period has expired.  End Error  Error: 2019-12-04 00:00:01.01     Code: 0xC0000033     Source: Full_Backup     Description: Integration Services evaluation period has expired.  End Error  Could not execute package because of error 0xC0000033.  Started:  12:00:00 AM  Finished: 12:00:01 AM  Elapsed:  0.516 seconds. The command line parameters are invalid.  The step failed.

Please provide the resolution steps for this issue....  

 

RAM


How to bring Database back ONLINE when in SUSPECT MODE in SQL SERVER 2000?

$
0
0

Dear All.

I am using SQL SERVER 2000 for my Databases. Recently, I faced a great crash of Server Hard Drive. Due to which I ran into a big horrible situation. Well Alas i got recovered data back. Now SQL SERVER 200 Says all databases in (SUSPECT MODE). I have put the Hard Drive back on its location. Now what i do to recover or bring back the DATABASES ONLINE. I am using SQL SERVER 2000. Pleas help. 

Thanks in ADV.

Log Shipping in SQLServer2019 error

$
0
0

Hi all,

I am trying to configure log shipping and getting following error in agent job history.(SQL Server 2019)

There was no problem with sql server 2017 and 2016 in same configuration.

The backup file was created normally but error message is logged.

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

2019-12-04 11:16:50.90 Starting transaction log backup. ID: '26c94b60-7380-4ddd-8dc7-ae2ae70630c7'

2019-12-04 11:16:50.90 *** ERROR: Unable to log history / error messages.(Microsoft.SqlServer.Management.LogShipping) ***

2019-12-04 11:16:50.90 *** error: Failed to convert parameter value fromSqlGuid to String.(System.Data) ***

2019-12-04 11:16:50.90 *** error: The object must implement IConvertible.(mscorlib) ***

2019-12-04 11:16:50.90 Retrieving backup settings ID: '26c94b60-7380-4ddd-8dc7-ae2ae70630c7'

2019-12-04 11:16:50.91 *** ERROR: Unable to log history / error messages.(Microsoft.SqlServer.Management.LogShipping) ***

2019-12-04 11:16:50.91 *** error: Failed to convert parameter value fromSqlGuid to String.(System.Data) ***

2019-12-04 11:16:50.91 *** error: The object must implement IConvertible.(mscorlib) ***

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

Can anyone tell me what is the problem in this?

n addition, I found the following phenomena:

Column [last_backup_file], [last_backup_date] of msdb.dbo.log_shipping_primary_databases and msdb.dbo.log_shipping_monitor_primary table is not updated. It's NULL.

It seems to be related to the error message noted above.



SQL Server Coallation Issue

$
0
0

Hi,

My SQL Server instance (SQL Server 2016) collation is  Japanese_BIN but i need to move an database from instance (SQL Server 2008) whose collation is Japanese_CI_AS and database itself collation is  SQL_Latin1_General_CP1_CI_AS. can you please let me knof is there any issue in doing it.

Regards,

Deepak

sys.index_columns.key_ordinal versus index_column_id

$
0
0

http://msdn.microsoft.com/en-us/library/ms175105.aspx

What is the difference between key_ordinal and index_column_id?

One one table where there is no PK indicated by there is a clustered unique index with four fields, the key_ordinal values reflect the order of the fields in the index, the index_column_id has 3-4 reversed.

So I mainly wonder what the purpose of index_column_id is?

Thanks.

Josh

ps - SQL 2008 64-bit enterprise.


Question on sys.dm_exec_query_plan

$
0
0

Hello,

Can anybody tell me why do the queries like these not return the database id?

I just don't know how to interpret such outputs: I do see there are plans in the cache but can't figure out which database the corresponding statements were compilied in?

Thank you in advance,
Michael

100% CPU - stays this way until the SQL service is restarted

$
0
0
<sd-content-toggle class="ng-isolate-scope" collapsed-changed="$ctrl.onChange(isCollapsed)" collapsed-text="More" expanded-text="Less" is-collapsed="true" lines-of-text="1" style="box-sizing:inherit;display:block;">
<mc-issue-description class="ng-scope ng-isolate-scope" issue-description="$ctrl.caseDetails.issueDescription" style="box-sizing:inherit;"><section class="issue-desc" style="box-sizing:inherit;display:block;">
We are running an SQL Server 2016 on Windows Server 2016 Standard.
The virtual server (32vCPU) running the SQL is running in Hyper-V. It has 32 CPU's and 96GB of RAM. (Only 24 are used for SQL Standard). 
We are running this VM on a Hyper-V failover cluster where the Physical nodes have 128GB of RAM and 32 CPU's. 
Storage is a Dell San. We informed with Dell and performed baseline storage tests to rule out obvious storage issues. 

Every afternoon the SQL server takes all of it's (24 cores) to 100% and it stays this way until the SQL service is restarted.
We are unable to trace the cause of the issues and we are looking for help to validate that the services are performing normal
</section></mc-issue-description>
</sd-content-toggle>

Kiran


DELETE operation is very slow

$
0
0
Hi All,

I have table with 1574963 rows and grown up to 1.21 Tera Bytes. Table has a clustered idx and additional nonclustered idx is created.

App team is trying delete/archive some data in small chunks.

CREATE TABLE [dbo].[LogData](
    [c1] [bigint] NOT NULL,
    [c2] [int] NOT NULL,
    [c3] [int] NOT NULL,
    [c4] [ntext] NOT NULL, -->>
    [c5] [int] NOT NULL,
    [c6] [int] NOT NULL,
    [c7] [int] NOT NULL,
    [c8] [int] NOT NULL,
    [c9] [int] NOT NULL,
    [c10] [int] NOT NULL,
    [c11] [nvarchar](255) NULL,  -->>
    [c12] [ntext] NULL,  -->>
    [c13] [int] NULL,
    [c14] [bigint] NOT NULL,
    [c16] [ntext] NULL, -->>
PRIMARY KEY CLUSTERED
(
    [c1] ASC,
    [c2] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
)
GO


CREATE NONCLUSTERED INDEX [AeLogDataPidInsId] ON [dbo].[AeProcessLogData]
(
    [c3] ASC,
    [c1] ASC,
    [c5] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
GO


Questions)

1) App team managed has to delete 1 million records, but when we trying to shrink the data file, the space is not getting released to OS. Why? how to reclaim the space?
2) The deletes are VERY VERY SLOW ... Anyone explain why DELETE's are slow?

Thanks,
Sam

Restore database failed

$
0
0

Hello,

I was trying to restore a database but it says failed, very backup data says verified but the restoration fails, tried also by using the following query

restore filelistonly
from disk = 'D:\GrantApp.bak'
go
restore database GrantApp
from disk = 'D:\GrantApp.bak' 
with move 'GrantApp' to 'C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\GrantApp.mdf',
move 'GrantApp_log' to 'C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\GrantApp_log.ldf'

but this gives me error as 

(2 row(s) affected)
Msg 3634, Level 16, State 1, Line 1
The operating system returned the error '5(Access is denied.)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\GrantApp.mdf'.
Msg 3156, Level 16, State 5, Line 1
File 'GrantApp' cannot be restored to 'C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\GrantApp.mdf'. Use WITH MOVE to identify a valid location for the file.
Msg 3634, Level 16, State 1, Line 1
The operating system returned the error '5(Access is denied.)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\GrantApp_log.ldf'.
Msg 3156, Level 16, State 5, Line 1
File 'GrantApp_log' cannot be restored to 'C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\GrantApp_log.ldf'. Use WITH MOVE to identify a valid location for the file.
Msg 3119, Level 16, State 1, Line 1
Problems were identified while planning for the RESTORE statement. Previous messages provide details.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.

Database backup failed

$
0
0

Could not backup the database. Got the following error message.

Ran a dbcc checkdb ('X')

Msg 1823, Level 16, State 2, Line 1

A database snapshot cannot be created because it failed to start.

Msg 7928, Level 16, State 1, Line 1

The database snapshot for online checks could not be created. Either the reason is given in a previous error or one of the underlying volumes does not support sparse files or alternate streams. Attempting to get exclusive access to run checks offline.

Msg 9001, Level 21, State 1, Line 1

The log for database 'X' is not available. Check the event log for related error messages. Resolve any errors and restart the database.

Msg 9001, Level 21, State 1, Line 1

The log for database '' is not available. Check the event log for related error messages. Resolve any errors and restart the database.

Are shared locks taken when a "linked server" is used to select from a table with (NOLOCK)?

$
0
0

Are shared locks taken when a "linked server" is used to select from a table with (NOLOCK)?

After a few tests running some SQL on database server A using a linked server pointing

to database server B and using “with(NOLOCK)”, it appears that shared read locks are taken.

from [linked server name].dbname.dbo.MHDISH with (NOLOCK)                                           --Deliveries

JOIN [linked server name].dbname.dbo.MHDISL with (NOLOCK) ON OQCONO = URCONO AND OQDLIX = URDLIX   --Delivery lines

JOIN [linked server name].dbname.dbo.OOHEAD with (NOLOCK) ON URCONO = OACONO AND URRIDN = OAORNO   --CO header file

JOIN [linked server name].dbname.dbo.OOLINE with (NOLOCK) ON URCONO = OBCONO AND URRIDN = OBORNO

          AND URRIDL = OBPONR AND URRIDX = OBPOSX                                                  --CO line file

JOIN [linked server name].dbname.dbo.MITMAS with (NOLOCK) ON OBCONO = MMCONO AND OBITNO = MMITNO   --Item Master


Table ID

# of shared locks

Table

1083775564

1

MHDISH

1211776020

1

MHDISL

1254503748

1

MITMAS

1268264369

17

OOLINE

2147356006

9

OOHEAD

Initially I thought that maybe the M3 application was taking the locks, but after doing the following twice

-  running sp_lock immediately before the SQL above and seeing no shared locks on the tables,

-  and then running sp_lock during the execution of the SQL above and seeing shared locks on the tables

… it appears to me that shared read locks are being taken.

SEMANTICSIMILARITYTABLE (Sql-2012 11.0.2100), why pull max of only 10 results?

$
0
0
Seems the current implementation of this Sql-View, will only pull max of 10 results in finding Similar (Near-Duplicate) docs.  Why this limit?  How to pull All Near-Dupe docs (essentially with similarity/relevancy ranking > .5)?

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


services not list in sql config mgr

$
0
0

Hi All,

On one of the sql server machine, when I open the sql server configuration manager, I am not able to see sql server services.

But if I open start->run->services.msc, I can see the services there. Why It is not showing up in SQL Server Configuration Manager, Anyone faced it ?

SQL Server 2016 Service Pack 1 (SP1)

Thanks,

Sam


I tried to restore a database and failed due to different versions

$
0
0

That's what appeared to me

TITLE: Microsoft SQL Server Management Studio
------------------------------

Restore of database 'altawqeef_DB' failed. (Microsoft.SqlServer.Management.RelationalEngineTasks)

------------------------------
ADDITIONAL INFORMATION:

System.Data.SqlClient.SqlError: The database was backed up on a server running version 15.00.1400. That version is incompatible with this server, which is running version 15.00.1200. Either restore the database on a server that supports the backup, or use a backup that is compatible with this server. (Microsoft.SqlServer.SmoExtended)

For help, click: https://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=15.0.18206.0+((SSMS_Rel).191029-2112)&LinkId=20476

------------------------------
BUTTONS:

OK

What is the solution

Tran Log backup to network backup device fails

$
0
0
Transaction logs for two databases on new SQL 2017 server are configured to backup to network-based backup devices using full UNC paths.  Job succeeds the first time, then fails after that with errors 3041 and 3266.  Full backups to same network location complete successfully.  Tran log backups to backup device pointed to local drive work fine.  It seems if permissions were the issue, the job would fail the first time.  Ideas?

Does an alias created in SQL Server Configuration Manager for a database server also have to be in the hosts file with the same IP address?

$
0
0
Does an alias created in SQL Server Configuration Manager for a database server also have to be in the hosts file with the same IP address?  We have a system admin who does not like to add entries to the hosts file (in ... \Windows\System32\drivers\etc\).

Query is executing forever ....

$
0
0

Hi All,

Need some help in query tuning. There is a query which is provided by app team. They says it gets timed out after 2 hours as they set query timeout = 2 hours. Now they reached out for help from DBA team.

We tried to run the query in Plan explorer to get the actual execution plan. The query is running over 9 hours but still doesn't finishes its execution. There is blocking involved. We have updated statistics with full scan. Still it runs forever ..... don't really know whats happening.

Status of the spid always showing "runnable". what does it mean?

When I open up the Windows task mgr and see the cpu utilization, it is 40-55% and not more than that which is normal.

From sql server configuration side, they are 12 logical cpu on the prod server but MAXDOP is set to 1. just wanted to mention this. Not sure how much it is related here in this context.We are running SQL Server 2012 sp4 Enterprise Edition.

I really don't understand whats the problem with the query can any help here.


dropbox link

https://www.dropbox.com/s/5ky0761iv6pmf36/QueryTuning.zip?dl=0

Collected below information so far.

- Query executing for more than 9 hours and still NOT YET finished !! - "Executing forever.PNG"
- sp_whoisactive output - "sp_WIA.PNG"
- Table and Index defintions - ddl.sql
- Query text - "src_qry.txt"
- Estimated Execution Plan ( collected using SQL Sentry Plan Explorer) -"EstimatedPlan.pesession"
- Table sizes and index fragmentation details "Tablesizes n Index Fragmentation details.PNG"
- When was stats got updated for those tables - "statistics update date.PNG"
- sp_configue settings -"sp_configure settings.PNG"
- cpu info - "cpu_info.PNG"
- memory info - "memory_info.PNG"

Thanks,

Sam

Who stopped my SQL Services ?

$
0
0

Hi All,

Is there a way to find out which windows user has stopped or started a SQL Service?
I testing purpose, on my local laptop i tried to stop SQL Agent service  and then tried to check the Windows Application Event log. It shows User as N/A ? why ?
Is there a way to find out who/which user has stopped the SQL Services ?

Thanks,
Sam

Viewing all 15872 articles
Browse latest View live