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

Login failed for User (Microsoft SQL Server, Error:18456)

$
0
0

Hi,

I am using SQL SERVER 2008. I was login through Windows Authentication and Unknowingly I havedeleted admin user (With name of my Computer e.g. "ABC-PC\ABC" ) under security=>Logins and restarted the SQL Server.

Now I am not able to connect to server using Windows as well as SQL Server Authentication Mode.

Please help me How can I create the same User again?

OR How can I connect to server using Windows or Sql Server Authentication??


Tempdb file remove problem

$
0
0

Hi All. I am trying to remove one of the tempdb logical file

alter database tempdb remove file tempdev2

and have the following error:

The file "H:\tempdb2.mdf" has been modified in the system catalog. The new path will be used the next time the database is started.
Msg 5042, Level 16, State 1, Line 1
The file 'tempdev2' cannot be removed because it is not empty.

then i run

USE tempdb;
GO
DBCC SHRINKFILE('tempdev2', EMPTYFILE)

and another error comes up:

Msg 8985, Level 16, State 1, Line 1
Could not locate file 'tempdev2' for database 'tempdb' in sys.database_files. The file either does not exist, or was dropped.

then I see in sys.database_files ,, I see

file_id file_guid type type_desc data_space_id name physical_name state state_desc size max_size growth is_media_read_only is_read_only is_sparse is_percent_growth is_name_reserved create_lsn drop_lsn read_only_lsn read_write_lsn differential_base_lsn differential_base_guid differential_base_time redo_start_lsn redo_start_fork_guid redo_target_lsn redo_target_fork_guid backup_lsn
1 NULL 0 ROWS 1 tempdev d:\databases\tempdb\tempdb.mdf 0 ONLINE 52008 -1 10 0 0 0 1 0 NULL NULL NULL NULL 27000000012600037 245940A4-BFC3-4F98-98B8-E56FFD49AE02 2014-07-12 14:00:05.247 NULL NULL NULL NULL NULL
2 NULL 1 LOG 0 templog d:\databases\tempdb\tempdb.ldf 0 ONLINE 3688 -1 10 0 0 0 1 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
3 997529E5-AD3D-4605-9CC0-5DAB53C91DFD 0 ROWS 1 tempdev2 H:\tempdb2.mdf 0 ONLINE 1748360 -1 128 0 0 0 0 0 3515000000034000001 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL

any one can help? am I afraid next time DB restart, the DB instance can't be start up.

log shipping: RESTORE LOG WITH CONTINUE_AFTER_ERROR?

$
0
0

Hi experts,

  I found the restore log on standby node failed with the error message like below. What happen? How do I prevent this error? How do I repair(rebuild a new log shipping DB)?

---  messages ---

Msg 4360, Level 16, State 1, Line 1
RESTORE LOG WITH CONTINUE_AFTER_ERROR was unsuccessful. Execution of the RESTORE command was aborted.
Msg 3013, Level 16, State 1, Line 1
RESTORE LOG is terminating abnormally.

--- errorlog ---

2014-07-16 07:00:00.42 Logon       Error: 18456, Severity: 14, State: 38.
2014-07-16 07:00:00.42 Logon       Login failed for user 'QCISAP\---'. Reason: Failed to open the explicitly specified database '---'. [CLIENT: <local machine>]
2014-07-16 07:01:49.52 spid60      Error: 4360, Severity: 16, State: 1.
2014-07-16 07:01:49.52 spid60      RESTORE LOG WITH CONTINUE_AFTER_ERROR was unsuccessful. Execution of the RESTORE command was aborted.
2014-07-16 07:19:56.38 spid59      FlushCache: cleaned up 247385 bufs with 162904 writes in 278549 ms (avoided 0 new dirty bufs) for db 7:0
2014-07-16 07:19:56.38 spid59                  average throughput:   6.94 MB/sec, I/O saturation: 161105, context switches 305229
2014-07-16 07:19:56.38 spid59                  last target outstanding: 34, avgWriteLatency 35

SQL 2014

$
0
0

We have been going to plan migrate 2005 to 2014, so that what is the syntax need to correct ?what are the other dis-compatibility sources available  

for sample we are getting below issue 

We're having an issue with SQL Server 2012 due to the presence of =* (RIGHT OUTER JOIN) operator.

1. there is any auto find  option to which  sps we have used and correct 

 KINDLY ASSIST TO US...


baskarlakshmi

sql server security patch

$
0
0

Hi team,

what are the main difference in sql server patch and sql serve security patch ?

what is the sql server security patch and how to apply the security patch.

DBM_INIT shows up in a profiler trace

$
0
0
What is DBM_INIT and how is it interpreted in trace? The eventClass is 50 and the eventSubClass is either 1 or 2.

Jo Lee

Missing index DMV

$
0
0
I tried to use missing indexes DMV (sys.dm_db_missing_index_group_stats, sys.dm_db_missing_index_groups and sys.dm_db_missing_index_details etc) to get suggested missing indexes. I got two suggested missing indexes like these: CREATE INDEX Misssing_Index_1 ON table (column1, column2) INCLUDE (column3) and  CREATE INDEX Misssing_Index_2 ON table (column1, column2) INCLUDE (column3, column4). I do need to set up index like this based on my system need. My question is - should I just create the Missing_Index_2 as it includes column3? Why does DMV recommend two indexes if so? Thanks.

In Avg. IOPS report the below query is generating very high I/O pls help to tune it

$
0
0

In Avg. IOPS report the below query is generating very high I/O pls help to tune it:

insert into @tempsamples                
     SELECT CASE WHEN @Direction = -1   THEN                 
         ROW_NUMBER() OVER(                 
         ORDER BY                  
       CASE                 
       WHEN @sortBy =   'SampleIDDescending' THEN cast(ID as nvarchar)                 
       WHEN @sortBy =   'SampleCategoryIDDescending' THEN SampleCategoryID                  
       WHEN @sortBy = 'SampleSequenceDescending'   THEN SampleSequence                   
       WHEN @sortBy =   'ClientSampleNoDescending' THEN ClientSampleNo                 
       WHEN @sortBy =   'SampleBarCodeDescending' THEN SampleBarCode            
       WHEN @sortBy =   'JobSampleConfigurationIDAndSampleSequenceID' THEN   CAST(IsNull(JobSampleConfigurationID,'') as bigint) + cast(SampleSequence as   bigint)      
          END DESC)                 
       ELSE                 
         ROW_NUMBER() OVER(                 
         ORDER BY                  
          CASE                
      WHEN @sortBy='SampleID' THEN   cast(ID as nvarchar)                   
            WHEN   @sortBy='SampleCategoryID' THEN SampleCategoryID                 
            WHEN @sortBy='SampleSequence'   THEN SampleSequence                   
            WHEN @sortBy='ClientSampleNo'   THEN ClientSampleNo                   
            WHEN @sortBy='SampleBarCode'   THEN SampleBarCode              
              WHEN @sortBy =   'JobSampleConfigurationIDAndSampleSequenceID' THEN   IsNull(JobSampleConfigurationID,'')
          END ,  
          CASE              
      WHEN   @sortBy='JobSampleConfigurationIDAndSampleSequenceID' THEN SampleSequence  
          END )                 
       END  AS 'RowNumber',   
     [ID] AS 'ID'               
     FROM dbo.SampleSearch(@locationID,   @sampleFlags, @sampleFlagsOperator, @jobID, @statusID, @sampleCategoryID,   @sampleSequence, @sampleBarCode, @clientSampleNo, @prefix, @suffix,@jobName,   @clientID, @jobDateFrom, @jobDateTo)               


Thanks


Filegroup Restoration Post FG Restore Index Not reflecting

$
0
0

Hi All,

I have a situation here.

I have created a Database. Then I created a Secondary File Group and Placed a File in it.

Now I created a Table on Primary File Group and Created 2 Indexes on secondary File Group

I took a backup of secondary Filegroup and then deleted the indexes. Now when I restore the secondary FIle Group I am unable to see indexes. Why Indexes are not being restored. Below is the script,

USE [master]
GO
CREATE DATABASE [MSSD_LAB] 
GO
USE [master]
GO
ALTER DATABASE [MSSD_LAB] ADD FILEGROUP [IDX_FG]
GO
ALTER DATABASE [MSSD_LAB] ADD FILE 
( NAME = N'MSSD_LAB_IDX', FILENAME = N'D:\MSSQLSERVER\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Data\MSSD_LAB_IDX.ndf' , 
SIZE = 2048KB , FILEGROWTH = 1024KB ) TO FILEGROUP [IDX_FG]
GO
USE [MSSD_LAB]
GO
CREATE TABLE TESTIDXBackup
(
Col_ClusIdx int
,Col_NClusIdx int
,Col_NoIdx varchar(10)
,Col_NoIdx1 nvarchar(10)
) ON [PRIMARY]
GO
--CREATE INDEX ON SECONDARY FILE GROUP
CREATE CLUSTERED INDEX [IDX_Clus_TESTIDXBackup_Col_ClusIdx] ON [dbo].[TESTIDXBackup] 
(
	[Col_ClusIdx] 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 [IDX_FG]
GO
CREATE NONCLUSTERED INDEX [IDX_Clus_TESTIDXBackup_Col_NClusIdx] ON [dbo].[TESTIDXBackup] 
(
	[Col_NClusIdx] 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 [IDX_FG]
GO
USE master
GO
--BACKUP SECONDARY FILE GROUP
BACKUP DATABASE MSSD_LAB
File = 'MSSD_LAB_IDX',
FILEGROUP = 'IDX_FG'
TO DISK = 'D:\MSSD_LAB\MSSQL_BACKUPS\Test_IDX_Backup\MSSD_LAB_IDX_FG.FLG'
GO
--DROP INDEXES ON SECONDARY FILEGROUP
USE MSSD_LAB
GO
IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TESTIDXBackup]') AND name = N'IDX_Clus_TESTIDXBackup_Col_ClusIdx')
DROP INDEX [IDX_Clus_TESTIDXBackup_Col_ClusIdx] ON [dbo].[TESTIDXBackup] WITH ( ONLINE = OFF )
GO
IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[TESTIDXBackup]') AND name = N'IDX_Clus_TESTIDXBackup_Col_NClusIdx')
DROP INDEX [IDX_Clus_TESTIDXBackup_Col_NClusIdx] ON [dbo].[TESTIDXBackup] WITH ( ONLINE = OFF )
GO
--RESTORE SECONDARY FILE GROUP
USE master
GO
ALTER DATABASE MSSD_LAB SET  SINGLE_USER with ROLLBACK IMMEDIATE
GO
RESTORE DATABASE MSSD_LAB
File = 'MSSD_LAB_IDX',
Filegroup = 'IDX_FG'
FROM DISK = 'D:\MSSD_LAB\MSSQL_BACKUPS\Test_IDX_Backup\MSSD_LAB_IDX_FG.FLG'
WITH RECOVERY,  MOVE 'MSSD_LAB_IDX' TO 'D:\MSSQLSERVER\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Data\MSSD_LAB_IDX.ndf'
GO
ALTER DATABASE MSSD_LAB SET  MULTI_USER with ROLLBACK IMMEDIATE

I am not sure what wrong I am doing. Any help greatly appreciated.


Thanks & Regards,
Manjunath C Bhat,
http://manjunathcbhat.blogspot.com
http://manjunathcbhat.wordpress.com

SQL Server Distributed Partitioning Views how to add a new node online

$
0
0

We are using distributed partitioning views in SQL Server 2012 Enterprise Edition for scaling out our data across more than one servers. Now we faced to question how to add a new node (server) into the scale outed db servers system without sending the servers down, so our users will be able to use them during the process as well.

For example we have 4 servers with scaled out data. When we add the new empty server, the CHECKINGs for the partitioning columns should be reorganized. But during the process the partitioning views are not working.

The High Availability, Always On or Failover Cluster approaches seem are not resolve the problems.

So my question is how to add new node online?


KH

Transaction replication DML [update] operation not allowing

$
0
0

We are configuration the transaction replication from production to DR site, while I am trying to perform the DML [update] operation in publication database, DML [update] operation not allowing.

Note: How we can perform DML [update]  operation in publication database. 


New database creation problem

$
0
0


While we are trying to create new database in test server it getting below error.

Error:

SQL Server 2012: NUMA node shown as offline without special affinity settings

$
0
0

My main production server has four NUMA nodes with two SQL Server 2012 instances on it. One of the instances has the CPU affinity set to use only one NUMA node, and sys.dm_os_nodes reflects that correctly. The other instance has no affinity settings, so it should show all 4 NUMA nodes as online, I would think, but it shows Node 3 as offline, which happens to be the node that's online for the other instance. Is there a bug in SQL Server 11.0.3128 (Enterprise)?

Unable to get contraints of Tables when I script all tables from Object Explorer

$
0
0

Hi All,

I was scripting all my Tables using object explorer, script doesn't have fireign keys I noticed. I verified at the portal but didnot get option through SSMS. One of developer helped me to get it. It is interesting and Quick.

Connect to SSMS->rightclick Database->click Tasks->GenerateScripts->Leave the default option Script entire database and all database objects and click Next->CLick Advanced tab and make true for all objects which you wnat to script and click ok->click Next->click Next->Finish


Swapna

Critical deletion query

$
0
0

 Suppose there is a table name as "Usersdetails"

ID                   Firstname                  Lastname

1                       Alex                             stewart

2                       Alex                             stewart

.                          .                                       .

.                          .                                       .

.                          .                                       .

120                   Alex                             stewart

suppose  Firstname +  Lastname = ' Alex stewart ' occurs 120 times in table

Now my question is I want that every users occurs only 65 times in table and I have to deleted remaining records...

How can I do that in a big table and in different kind of user name and occurrence of users may change??

please help...


Custom File Extension for Microsoft Access Text Driver (*.txt, *.csv)

$
0
0

I'm trying to use a custom file extension for the Microsoft Access Text Driver (*.txt, *.csv) driver.

I have updated the FileExtns registry to have my new extension.

When I issue the following it does not work.

select[NoName] fromopenrowset('MSDASQL'
          
,'Driver={Microsoft Access Text Driver (*.txt, *.csv)};
                DefaultDir=c:\filedir'

          
,'select * from "file.lst"')

If I make the file a .csv it works fine.  However, if it has an extension of not CSV or TXT (in this case .lst, which is in the registry setting) extension it throws the following error and cannot seem to find a solution to it. 

OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Text Driver] Cannot update. Database or object is read-only.". Msg 7350, Level 16, State 2, Line 1 Cannot get the column information from OLE DB provider "MSDASQL" for linked server "(null)".

In addition, (although I can probably find this elsewhere), I need to have the first line 'BLANK' so that it does not miss data (there is no header row).  Is there  a way to use OPENROWSET without BULK to basically include all rows as data?

Any help is appreciated.

Contained DB best practices

$
0
0

Hello!

A standard procedure for converting an ordinary db to the contained one is as follows:

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

sp_migrate_user_to_contained @username = N'Barry',@rename = N'keep_name', @disablelogin = N'do_not_disable_login' ;

On the other hand, this article says:

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

"As a best practice, do not create contained database users with passwords
who have the same name as SQL Server logins.
"-

But the commands mentioned at the begining of this post do create
"contained database users with passwords who have the same name as SQL Server logins."

Does it mean we must NOT use @rename = N'keep_name' (or @disablelogin = N'do_not_disable_login')
to follow best practices for contained DBs?

Thank you in advance,

Michael





After setting database read_only if i take transaction log backup with no truncate , does it have side affect?

$
0
0

I want to take transaction backup of database, but i want the log have the last transaction in it.

With no truncate option supports this. But via sql manegment studio, it leaves the database recovery state.

when you leave the database recovery state, you have to restore the last transaction to get normal. And after restoring the transaction log you destroy the backup sequence.

Instead i found a new method, i want to ask if it has a side affect;

Scenerio;

1)  set database read_only

2) take transaction backup with no truncatewith t-sql (By this way you do not have to specify to leave the database  recovery mode)

3) And other transaction log backups (with truncate_only) can go on..... And you are sure that,the last transaction is in the first transaction log backup that we took via no truncate option

Is there a problem with this scenerio?

Fully contained database

$
0
0

Hello!

My MS 70-462 exam guide says:


This article (http://msdn.microsoft.com/en-us/library/ff929055.aspx) states:

"If the containment setting of a database is changed from NONE to eitherPARTIAL or FULL, then user access can be granted by creating contained database users with passwords. "



I've seen a lot of MSDN articles regarding Partially Contained Databases but seen nothing on Full contained DBs. I can hardly admit those documents(70-462 testbook and Security Best Practices with contained databases article) are not correct...but can anyone give me a refferal to some artical on fully (NOT partially!) contained DB?

Thank you in advance,

Michael



Error 606 occured - Metadata inconsistency for temp table

$
0
0

Hello,

we currently have an issue on a production server running SQL Server 2005 Standard:

Executing a stored procedure, which again executes another stored procedure in which a temporary table #PIVOT_ITEMS is created and filled.

The stored procedure throws an exception that error 606 has occurred. Looking at the SQL Server logs, it contains:

"Metadata inconsistency. Filegroup id 0 specified for table
'dbo.#PIVOT_ITEMS' does not exist. Run DBCC CHECKDB or
CHECKCATALOG
".

DBCC CHECKDB didn't help, so what could this error mean on a temporary table?

I searched a lot in the web, but nobody else ever seemed to have this error 606...

Thanks a lot for helping!

Regards, Jens

Viewing all 12644 articles
Browse latest View live


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