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

I have much rows in a single table 2934167078

$
0
0

I have got a new project in which one table has 2934167078 rows and no primary key in the table.Whenever I want to create some maintenance plan the management studio got hang.

I want to add a primary key also for peer to peer replication purpose but all is stuck due to such large size.

Kindly help


Thanks


To get a SYSTEM NAME even using sa or Group login other than Windows Authentication

$
0
0

how to get system name in username when we write a select query Select SUser_sname() in sql server 2008 r2.

Actually , requirement  is  I have to give a sql serevr login to the client.

NOTE : I cant create a Windows Authentication to the client.

So, I create a login Called    Satish with PasswordSatish@123  ,

when client login with Satish , and if he selects a  Select SUser_sname() he will get aSatish as Output , but my requirement is i have to display a client name(System Name).

Very Urgent , Please do me need full.

Restore

$
0
0

When i changed a backup  path (in Maintenance plan) from one disk(F - Drive) to Another disk (G - Drive), and trying to restore that time i noticed user name have been changed from SA to NT AUTHORITY\NETWORK SERVICES ,

1) Can you please explain why it happens ??

2)If i want to change a user name to SA (how can i do that)??

3)Does it effect a database ??

Thanks in Advance...


check point query information

$
0
0

Hello Team,

one of my production server i am continually getting this error:

[CHECK POINT FREE SPACE QUERY TIME OUT]

this information we are getting through third party tools and IT team raise ticket to DBA team,

Note:we checked sql server error log  due to this issue but there is no information for this issue each and every think works fine.

how we can resolve this issue ,this alert getting daily 4 or 5 times.

 

Unable to start default LocalDB instance on Windows 8 x86

$
0
0

Cannot start the default LocalDB instance, in our application or by typing in 'sqllocaldb s "v11.0"' on the command line. This issue only occurs on Windows 8 x86.  Works fine on Windows 7 x86/64 and on Windows 8 x64.  Have gotten the same results on a physical Windows 8 x86 box, as well as on a Windows 8 x86 VM we created to retest the issue.  ASP.NET 4.5 has been enabled in Windows Features.  Here's what the Instance's error log has to say:

2012-11-01 16:22:17.90 Server      Microsoft SQL Server 2012 - 11.0.2318.0 (Intel X86)
    Apr 19 2012 11:55:51
    Copyright (c) Microsoft Corporation
    Express Edition on Windows NT 6.2 <X86> (Build 9200: ) (Hypervisor)

2012-11-01 16:22:17.90 Server      (c) Microsoft Corporation.
2012-11-01 16:22:17.90 Server      All rights reserved.
2012-11-01 16:22:17.90 Server      Server process ID is 2932.
2012-11-01 16:22:17.91 Server      System Manufacturer: 'Microsoft Corporation', System Model: 'Virtual Machine'.
2012-11-01 16:22:17.91 Server      Authentication mode is MIXED.
2012-11-01 16:22:17.91 Server      Logging SQL Server messages in file 'C:\Users\Testing\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\v11.0\error.log'.
2012-11-01 16:22:17.91 Server      The service account is 'TestWin8x86\Testing'. This is an informational message; no user action is required.
2012-11-01 16:22:17.91 Server      Command Line Startup Parameters:
     -c
     -S "MSSQL11E.LOCALDB"
     -s "LOCALDB#C930B37E"
     -d "C:\Users\Testing\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\v11.0\master.mdf"
     -l "C:\Users\Testing\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\v11.0\mastlog.ldf"
     -e "C:\Users\Testing\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\v11.0\error.log"
2012-11-01 16:22:18.14 Server      SQL Server detected 1 sockets with 2 cores per socket and 2 logical processors per socket, 2 total logical processors; using 2 logical processors based on SQL Server licensing. This is an informational message; no user action is required.
2012-11-01 16:22:18.14 Server      SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2012-11-01 16:22:18.14 Server      Detected 2047 MB of RAM. This is an informational message; no user action is required.
2012-11-01 16:22:18.14 Server      Using conventional memory in the memory manager.
2012-11-01 16:22:18.21 Server      Node configuration: node 0: CPU mask: 0x00000003:0 Active CPU mask: 0x00000003:0. This message provides a description of the NUMA configuration for this computer. This is an informational message only. No user action is required.
2012-11-01 16:22:18.22 Server      Using dynamic lock allocation.  Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node.  This is an informational message only.  No user action is required.
2012-11-01 16:22:18.23 Server      Software Usage Metrics is disabled.
2012-11-01 16:22:18.23 spid8s      Starting up database 'master'.
2012-11-01 16:22:18.26 spid8s      1 transactions rolled forward in database 'master' (1:0). This is an informational message only. No user action is required.
2012-11-01 16:22:18.28 spid8s      0 transactions rolled back in database 'master' (1:0). This is an informational message only. No user action is required.
2012-11-01 16:22:18.36 Server      CLR version v4.0.30319 loaded.
2012-11-01 16:22:18.44 Server      Common language runtime (CLR) functionality initialized using CLR version v4.0.30319 from C:\Windows\Microsoft.NET\Framework\v4.0.30319\.
2012-11-01 16:22:18.44 spid8s      SQL Server Audit is starting the audits. This is an informational message. No user action is required.
2012-11-01 16:22:18.44 spid8s      SQL Server Audit has started the audits. This is an informational message. No user action is required.
2012-11-01 16:22:18.49 spid8s      SQL Trace ID 1 was started by login "sa".
2012-11-01 16:22:18.50 spid8s      Server name is 'TESTWIN8X86\LOCALDB#C930B37E'. This is an informational message only. No user action is required.
2012-11-01 16:22:18.51 spid11s     Server local connection provider is ready to accept connection on [ \\.\pipe\LOCALDB#C930B37E\tsql\query ].
2012-11-01 16:22:18.52 spid11s     Dedicated administrator connection support was not started because it is disabled on this edition of SQL Server. If you want to use a dedicated administrator connection, restart SQL Server using the trace flag 7806. This is an informational message only. No user action is required.
2012-11-01 16:22:18.52 spid8s      Failed to verify Authenticode signature on DLL 'C:\Program Files\Microsoft SQL Server\110\LocalDB\Binn\\ftimport.dll'.
2012-11-01 16:22:18.53 spid9s      Starting up database 'mssqlsystemresource'.
2012-11-01 16:22:18.53 spid8s      Error: 17204, Severity: 16, State: 1.
2012-11-01 16:22:18.53 spid8s      FCB::Open failed: Could not open file e:\sql11_main_t.obj.x86release\sql\mkmastr\databases\objfre\i386\MSDBData.mdf for file number 0.  OS error: 3(The system cannot find the path specified.).
2012-11-01 16:22:18.53 spid8s      Error: 5120, Severity: 16, State: 101.
2012-11-01 16:22:18.53 spid8s      Unable to open the physical file "e:\sql11_main_t.obj.x86release\sql\mkmastr\databases\objfre\i386\MSDBData.mdf". Operating system error 3: "3(The system cannot find the path specified.)".
2012-11-01 16:22:18.53 spid9s      The resource database build version is 11.00.2318. This is an informational message only. No user action is required.
2012-11-01 16:22:18.58 spid9s      Starting up database 'model'.
2012-11-01 16:22:18.58 spid9s      Error: 17204, Severity: 16, State: 1.
2012-11-01 16:22:18.58 spid9s      FCB::Open failed: Could not open file e:\sql11_main_t.obj.x86release\sql\mkmastr\databases\objfre\i386\model.mdf for file number 1.  OS error: 3(The system cannot find the path specified.).
2012-11-01 16:22:18.58 spid9s      Error: 5120, Severity: 16, State: 101.
2012-11-01 16:22:18.58 spid9s      Unable to open the physical file "e:\sql11_main_t.obj.x86release\sql\mkmastr\databases\objfre\i386\model.mdf". Operating system error 3: "3(The system cannot find the path specified.)".
2012-11-01 16:22:18.58 spid9s      Error: 17207, Severity: 16, State: 1.
2012-11-01 16:22:18.58 spid9s      FileMgr::StartLogFiles: Operating system error 2(The system cannot find the file specified.) occurred while creating or opening file 'e:\sql11_main_t.obj.x86release\sql\mkmastr\databases\objfre\i386\modellog.ldf'. Diagnose and correct the operating system error, and retry the operation.
2012-11-01 16:22:18.58 spid9s      File activation failure. The physical file name "e:\sql11_main_t.obj.x86release\sql\mkmastr\databases\objfre\i386\modellog.ldf" may be incorrect.
2012-11-01 16:22:18.58 spid9s      Error: 945, Severity: 14, State: 2.
2012-11-01 16:22:18.58 spid9s      Database 'model' cannot be opened due to inaccessible files or insufficient memory or disk space.  See the SQL Server errorlog for details.
2012-11-01 16:22:18.58 spid9s      SQL Trace was stopped due to server shutdown. Trace ID = '1'. This is an informational message only; no user action is required.

Powershell - Out-File Error on collection of table objects

$
0
0

Hello all,

Getting error on scripting out table objects...works fine with one table but, not many...

Error:

Out-File : The specified wildcard pattern is not valid: Object[]

At P:\Work\Powershell\script out table objects from sql server.ps1:96 char:54

+                                     $ScriptCreate.Script($smoObjects) | out-File <<<<  -Force $scriptfile    

    + CategoryInfo          : NotSpecified: (:) [Out-File], WildcardPatternException

    + FullyQualifiedErrorId : RuntimeException,Microsoft.PowerShell.Commands.OutFileCommand

				#The first thing you need to do is load the appropriate .NET assemblies used by SMO.						
				[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | out-null	
				$serverInstance = New-Object ('Microsoft.SqlServer.Management.Smo.Server') "myserver"
				#String date variable
				$DateFolder = (get-Date).tostring("yyyyMMddHHssmm")							

				$ScriptCreate = new-object ("Microsoft.SqlServer.Management.Smo.Scripter")$serverInstance			
			    #Loop through databases
				foreach($sqlDatabase in $serverInstance.databases) 
				{	
					# Set which database we are on
					$sqlDatabaseName = $sqlDatabase.name -replace '[\\\/\:\.]',' ' # remove characters that can cause problems
					# Database directory full path
					$DatabaseDirPath =  "\\myserver\myshare\SQLobjectbackup\DatabaseScripts\" + $($sqlDatabaseName)					
					 #for a single database or testing	
					 IF ($sqlDatabase.name -eq "mydatabase")
					 {	
						 	# Set object filters
							$procs = $sqlDatabase.StoredProcedures | Where-object {-not $_.IsSystemObject -and -not $_.IsEncrypted }
							$views = $sqlDatabase.views | Where-object {-not $_.IsSystemObject -and -not $_.IsEncrypted }
							$tables = $sqlDatabase.tables  | Where-object {-not $_.IsSystemObject  }	
							$udfs = $sqlDatabase.UserDefinedFunctions | Where-object {-not $_.IsSystemObject -and -not $_.IsEncrypted -and $_.name -notlike "dm_*" }							
							#print database name"*****Scripting.. $sqlDatabaseName"		
								 #TABLES"""********Scripting... TABLES...."							 
							 if($tables -ne $null)
							 {
										# Set Type of ObjectName
										$TypeObjectName = $tables.GetType().Name
										# Complete save directory path
										#$CompleteFileSavePathName = $DatabaseDirPath + "\" + $DateFolder + "\" + $TypeObjectName + "\" 
										$CompleteFileSavePathName = $DatabaseDirPath + "\" + $TypeObjectName + "\" 	
										# Create directory
										new-item "$CompleteFileSavePathName" -type directory -force | out-null	
										# Set full path for procedure to variable
   								        $scriptfile = $CompleteFileSavePathName + "\" + "AllTables.sql"
										# SetScriptOptions	
   										$ScriptCreate.Options.FileName = $scriptfile
										$ScriptCreate.Options.DRIAll = $true # All Constraints 
										$ScriptCreate.Options.ClusteredIndexes = $True 
										$ScriptCreate.Options.Indexes = $true 
										$ScriptCreate.Options.Triggers = $true 
										$ScriptCreate.Options.IncludeIfNotExists = $true
										$ScriptCreate.Options.SchemaQualify = $true 
										$ScriptCreate.Options.AllowSystemObjects = $false
										$ScriptCreate.Options.AppendToFile = $true
										$ScriptCreate.Options.ExtendedProperties = $true 
										$ScriptCreate.Options.WithDependencies = $True
									#Need a collection of tables to script
									$smoObjects = New-Object Microsoft.SqlServer.Management.Smo.UrnCollection
										foreach($table in $tables) 
											{																							   
												 If ($table.IsSystemObject -eq $FALSE) 												
												   { 
														# Set table name to variable
														$ObjectName = $table.name 	
														#print which table we are scripting										"***********Scripting... table: $ObjectName ..."													
														$smoObjects.Add($table.Urn)	
													}
											}
									$ScriptCreate.Script($smoObjects) | out-File -Force $scriptfile 	

						}
					} 
					
				}
 
				

thanks

gv

Which encryption method does SQL 2012 use?

How to verify connection encryption status with minimal permissions?

$
0
0

Hello-

My goal is to verify that all connections made by a program are encrypted at program startup.  My first idea was to check the connection string for the appropriate tokens, but I wanted something more bulletproof.  I found that the following query should do the trick:

SELECT [encrypt_option] FROM [sys].[dm_exec_connections] WHERE [session_id] = @@SPID;

However, selecting from this table requires that a user be granted VIEW SERVER STATE.

I suppose I have two related questions:

  1. Is there a way to view one's own connection's encryption state without needing VIEW SERVER STATE or any other overly-broad permission?

  2. Is there any particular danger in a user having VIEW SERVER STATE?  I understand a connection will be able to view metadata about other connections, and that alone may not be too concerning depending on what that metadata is.  This is not a shared user environment so much as it is a shared service environment, and I wish to maintain isolation between services in the event that one were to be compromised by an attacker.  If there is the potential to leak credentials, query text, or data between users I am concerned.  If they can just see a list of all the connections to a server, I am not so much.


Thanks



cant drop a partition scheme due to wrong dependencies!!!

$
0
0

Hi,

I found that my database has partition schèmes and functions created by the index tuning wizard.

But I can remove them, SQL Server think there is a dependency to a table in the database.

but the target table didnt use any partition!!! (and none of the indexes use a partition)

so its a false dependency.

and now I'm not able to drop the partition scheme (and function).

what can I  do to solve this false dependency issue?

Master and recource database

$
0
0
What is the main difference between Master and Resource Database?

Selectively flushing BUFFER CACHE

$
0
0

We use SQL EXPRESS 2008; so we are limited to 1GB memory. The following query, lists the top databases using highest buffer cache. In my case, 2 insignificant databases are listed at the top. The critical database is number 3--and it performs slow. I don't mind the other 2 performing slow. They run a process twice a day, and do nothing. This heavy process blows-up the buffer cache. Is there a way to selectively flush the buffer cache?  (I'm already using 

 DBCC FREESYSTEMCACHE('SQL Plans') 
 DBCC FLUSHPROCINDB ()

But they were NOT much useful. 

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

SELECT db_name(database_id) as dbname,
       count(page_id)  as pages,
   convert(decimal(20,2),count(page_id)*8192.0/1048576) as Mb
from sys.dm_os_buffer_descriptors
group by database_id
order by convert(decimal(20,2),count(page_id)*8192.0/1048576) desc

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


Date Time Conversion to Custom Format

$
0
0

Hi All,

I am using SQL Server 2012 sp1 .I have a table column with the following Date Time values.

BLDCHKDT

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

2013-06-19 00:00:00.000

2013-07-22 00:00:00.000

2013-08-21 00:00:00.000

2013-09-20 00:00:00.000

2013-11-18 00:00:00.000

I would like to retrieve the date and Time in the following formats:

Date: 19062013

Time: 00000000

Is it possible? I have reviewed the SQL Server help documentation for the FORMAT, CAST and CONVERT functions and I can’t seem to get any headway.

So far I have attempted the following conversions:

N.B Please note that I am converting to Date time to string to facilitate a flat file export.

--Retrieving Date

SELECT[DATE-BLDCHKD]= CONVERT (VARCHAR (20),BLDCHKDT, 112)

FROMTABLEA

DATE-BLDCHKD

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

20130619

20130722

20130821

20130920

20131118

--Retrieving Time

SELECT[TIME-BLDCHKD]= CONVERT (VARCHAR (20),BLDCHKDT, 24)

FROMTABLEA

TIME-BLDCHKD

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

00:00:00

00:00:00

00:00:00

00:00:00

00:00:00

00:00:00

00:00:00

00:00:00

I appreciate your insights. Thank you in advance.


The Best thing in Life is Life

cumulative update vs Hot fix

$
0
0

hello team,

what is the sql server cumulative update?,what is the hot fixs? and what is the sql server service packs?.

when we can use above three  cumulative update, hot fixs and service packs.


DBCC CHECKTABLE (,REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS, ALL_ERRORMSGS hanging at 9% for days

$
0
0

I try to recover my 10 TB big SQL DB, but the process hangs at 9-10 % 

I tried with DBCC CHECKTABLE  instead but one of the largest tables stopped at 97.34% finished

Want can I do?

decoding Query Plan XSD (RelOp)- what is the difference between OutputList and DefinedValues

$
0
0

under http://schemas.microsoft.com/sqlserver/2004/07/showplan/showplanxml.xsd

we have 

<xsd:complexType name="RelOpType">
-<xsd:sequence>

<xsd:elementname="OutputList" type="shp:ColumnReferenceListType" />

...

-<xsd:complexType name="RelOpBaseType">
-<xsd:sequence>

<xsd:elementname="DefinedValues" type="shp:DefinedValuesListType" minOccurs="0" maxOccurs="1" />

which is defined as

<xsd:complexType name="DefinedValuesListType">
-<xsd:sequence>
-<xsd:element name="DefinedValue" minOccurs="0" maxOccurs="unbounded">
-<xsd:complexType>
-<xsd:sequence>
-<xsd:choice>
-<xsd:element name="ValueVector">
-<xsd:complexType>
-<xsd:sequence>
<xsd:elementname="ColumnReference" type="shp:ColumnReferenceType" minOccurs="2" maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:elementname="ColumnReference" type="shp:ColumnReferenceType" />
</xsd:choice>
-<xsd:choice minOccurs="0" maxOccurs="1">
<xsd:elementname="ColumnReference" type="shp:ColumnReferenceType" minOccurs="1" maxOccurs="unbounded" />
<xsd:elementname="ScalarOperator" type="shp:ScalarType" />
-<!--
 unbounded for union case 
-->
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>

</xsd:complexType>

I can't seem to find a difference between the data in OutputList and DefinedValues. what am I missing? What is DefinedValues supposed to be? TIA.


Mordechai Danielov


Measuring Performance Gain from Changing Power Management from Balanced to Performance

$
0
0
I have seen the recommendation to set the Power Management setting in Windows to use the High Performance plan in Windows rather than the Balanced plan.  How would I measure performance improvements from making this change?  I am curious because I want to be able to prove to the Windows Admin that making these changes is a good idea.

Lee Markum

Information about linked server details including remote login in use

$
0
0

After joining a new organization, one day an application support came to ask brief information about all the SQL Server linked servers and few more important configuration details.

They were looking to upgrade their application and database. In order to know all possible sources of their data feed, the guy needed this information.

Most of the information could have been taken by running sp_linkedservers but because login information was also required I preferred to run following query to collect the required data.

SELECT

     srv.name as LinkedServerName

     ,srv.product

     ,srv.provider

     ,srv.data_source

     ,srv.catalog

     ,sp.name

     ,lgn.uses_self_credential

     ,lgn.remote_name remote_login_in_use

FROM

     sys.serversAS srv JOIN sys.linked_loginsAS lgn

ON srv.server_id = lgn.server_idAND srv.is_data_access_enabled= 1

LEFTJOINsys.server_principalsAS sp ON lgn.local_principal_id= sp.principal_id

WHAT IS actual data source Server Name

Although they got the information, but they could not recognize the actual server names as highlighted in thesrv_data_source column. All they said that, the linked servers were created by DBAs.

  1. I tried to ping these names from my user desktop, but could not Ping request could not find host.
  2. Tried to check the SQL Server Aliases but there were no alias defined for any of the server names.
  3. Finally I looked into the host file and found the entries. The ping from my desktop did not work because the host file entries are local to the database server. Because SQL Server instance is sitting on the same server where the names are entered into the host file, it was able to resolve the host names. Also Ping from the database server worked. The host file looked like as below (C:\Windows\System32\drivers\etc)

Hope this information helps you!!.


Warm Regards, Ajay



Moving Database

$
0
0

How to move database from one instance to another instance of the same SQL Server Version using code.

What are the pre and post requisites I need to take care before I proceed.

Please help me ASAP with this so that I can perform this task in my production environment

How to take SQL database backup in .zip format ?

$
0
0
Hi ,

I want to take the user database backup in .zip format on sql server 2005 .
Could you please assist me & share the solution with me .

Thanks ,

identify database file usage

$
0
0

I would like to identify over the last X seconds how much data has been written and read from each database file by SPID, is this possible? I want gather information on our busiest files and processes.

Id like to be able to do this in TSQL rather than using profiler.

Viewing all 15872 articles
Browse latest View live


Latest Images

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