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

SP execution inside a set based procedure: nothing

$
0
0

Hi all of you,

I need to recover one Output value from one SP and does not work. Nevertheless, my sp execute in every loop successfully

This is one example (the complete code is boring) just for illustrate my problem:

declare @ni table(id integer, data date) declare @RandomDate date; declare @cont integer = 0; while @cont < 10 begin insert into @ni(id,data) select 1,@RandomDate EXEC utilities.ReturnRandomDate @AlAtzar = @RandomDate set @cont +=1 end

select * from @ni

SP:

CREATE PROCEDURE [Utilities].[ReturnRandomDate](@AlAtzar date = '2016-02-21' OUTPUT)
AS
BEGIN
SELECT convert(date,dateadd(day, (abs(CHECKSUM(newid())) % 23650) * -1, getdate() - 3000))
END




How to configure automated email alert in SQL Server 2012 based on query results

$
0
0

I need to identify and be notified when records in my SQL Server 2012 R2 database table meet a specific condition. For example, when a record in the trans_record table has any entries in the “status” column of “error”.

The query is simple enough and I have setup an SSIS package to query the table with the appropriate “where” clause. I followed this with a SQL Agent job to run the SSIS package daily at 7:00am and export the offending records to a flat text file.

What I need to understand is how I can be emailed only when a record is found with the query performed by the SSIS package. It appears that the SSIS package will always create a file regardless if any records are found.

I see that SQL Server supports Alerts and defined Operators to be notified, but I don’t understand how to be notified only if my query returns a valid record.

How can I set this up in SQL Server?

Thanks

How to refresh only scheme and not the data.

$
0
0

Hi

Cloud someone please let me know how to refresh only scheme and not the data?
As per my knowledge, the normal refresh will replace the destination data with source data.
If I do only schema refresh, the data will be removed and only table’s structure will be created.
Please let me know if it is not correct.Also,please let me know the diffenece between these two.

Thanks in advance.

Setting output variables in a SP by using Sql Functions

$
0
0

Hi all of you,

I have got one SP which returnS one random date.


I've tried to do this using UDF but it seems newid() function is not allowed there.

The last line does not work. I think it would be clearer than the first one, what do you think?

ALTER PROCEDURE [Utilities].[ReturnRandomDate](@AlAtzar date = '2016-02-21' OUTPUT)

ALTER PROCEDURE [Utilities].[ReturnRandomDate](@AlAtzar date = SELECT GETDATE() OUTPUT

Source sp code:

CREATE PROCEDURE [Utilities].[ReturnRandomDate](@AlAtzar date = '2016-01-21' OUTPUT)
AS
BEGIN
SELECT convert(date,dateadd(day, (abs(CHECKSUM(newid())) % 23650) * -1, getdate() - 3000))

END

EXEC Utilities.ReturnRandomDate



Logical Reads vs. Physical Reads

$
0
0
- What is the difference between logical and physical reads? Does tempDB come into picture? And can high logical reads cause performance issues?

Restoration failure :- backup set holds a backup of a database

$
0
0

Hi All, 

Really need your assistance and help, I have problem and issue on Data Warehouse environment, where when doing a restoration received error as below 

Error :- 

The backup set holds a backup of a database other than the existing 'XXX' database 

Restore database is terminating abnormal .

Was tried few solution such as WITH MORE, detach, create back and run restoration database still nowt work.

Need your suggestion and solution for this issue .

Appreciate your kind assistance. 

Environmnt : SQL Server 2008 Enterprise . 

Thank you

Amy Badri 


DBCC CHECKDB issue in Azure. - MSSQL_DBCC22". Operating system error 80: "80(The file exists.)".

$
0
0

I have an issue running DBCC CHECKDB on one of our SQL Server Azure wm's .

DBCC CHECKDB are runing just fine on all databases on the server except one, which fails with the error below.

The one database that fails has it's data files in Azure premium storage (https:\xxx.xxxxx.blob.core.windows.net\xxxx), the rest is on classic storage, as is the Azure VM server itself.

While running the DBCC Check db against the failing database, it seems that the DBCC snapshot file generated, does not get cleaned up correctly which I believe to be the cause of the error.(https://xxxxxxxx.blob.core.windows.net/xxxx/xxxxxxxmdf_MSSQL_DBCC22) The file can be see from the Azure storage interface. 

 I cannot find a solution for this, so any help will be much appreciated! 

Error message:---------------------------------------------------------------------------- 

Msg 1823, Level 16, State 2, Line 1
A database snapshot cannot be created because it failed to start.
Msg 1823, Level 16, State 8, Line 1
A database snapshot cannot be created because it failed to start.
Msg 5120, Level 16, State 144, Line 1
Unable to open the physical file "xxxxxx.xxxxxxx.xxxxxx/xxxx/xxxxxx.mdf_MSSQL_DBCC22". Operating system error 80: "80(The file exists.)".
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 5030, Level 16, State 12, Line 1
The database could not be exclusively locked to perform the operation.
Msg 7926, Level 16, State 1, Line 1
Check statement aborted. The database could not be checked as a database snapshot could not be created and the database or table could not be locked. See Books Online for details of when this behavior is expected and what workarounds exist. Also see previous errors for more details.


Database size increase

$
0
0

Hi All

Is there any way, to lower the increase in DB size after re-indexing, if we can't resist completely increasing size of database.


how to count number of lines in a row for particular column

$
0
0

Hi all,

 i have a table with column reference of type nvarchar(MAX)

a single row of it has data splitted into many lines .data is as follwos:

"jb 12000 paid
jb 700 paid
jb 700 paid
this is a toy
a car
i10 is a car
turkey is a country
golf is a game
12123141255
12345678910
movie is cinema"

the single cell has the above data spliited into more than 10 lines.now, how can i count the number of lines per in particular row

so that i can use that number of lines count in ssrs report.please help..

thanx in advance


lucky

Error With Service Broker

$
0
0

Good Morning Forum

This morning the SQL Server logs had the following message 775 times: -

Service Broker needs to access the master key in the database 'DATABASE NAME'. Error code:26. The master key has to exist and the service master key encryption is required

The database in question does have Service Broker enabled; does anyone know what could be causing this error?


Please click "Mark As Answer" if my post helped. Tony C.

Error while Exporting a SSIS package from SSMS

$
0
0
Hi All,

Need some help.

Today across a issue. Using SQL Server 2012 SP1 Enterprise Edition. Try to Export SSIS package in SSMS and it throws me an error message saying. "Please create a master key in the database or open the master key in the session before performing this operation."

Any idea why we get this error ????
Adding to it, after having some conversation with IT team, came to know that the Server Name has been renamed. But now servernames seems good from the below query.

select @@SERVERNAME, SERVERPROPERTY('servername')
server123   SERVER123

Thanks in advance.

high CPU utilization of sqlserver.exe

$
0
0

Hi Team

We have SQL server 2008 running on the OS Win server 2008 R2.

configuration : 32 GB RAM / 8 CORE

The SQLserver.exe process is taking the high cpu utilization. How to improve this.

recently we have upgraded from 16 GB/ 4core to 32GB/8 core.

Please suggest

Thanks

rameena

SQL Server Update error message. (Standard 2014 -> Sql Server 2016 RC1)

$
0
0

Good Afternoon,

I am testing a SQL Server Update Path(Standard 2014 -> Sql Server 2016 RC1).

An error popup box occurs on the "Feature Rules" page. The message states "The specified edition upgrade from Standard edition to target Evaluation edition is not supported......"

I did some online research for Sql 2016 upgrade paths. One of the links states "2014 standard" can be upgraded to "2016 standard".

Do I need to wait for a newer released version of SQL 2016 or is there some other reason for the message which prevents the upgrade?

Thanks

Joe

Why Can I Connect To Aerver But Not Link To It

$
0
0

This makes no sense to me, so I hope that someone can provide an explanation.

I'm working with databases on several servers via SSMS 2014. I have been able to link to other servers. For my current project, I need to work with data from LanSweeper. I am able to connect to the database on the server, see all the various database objects, do queries, etc.

Since I will need to join data from the LanSweeper database to data in other databases, I went to set it up as a linked database.  I know I gave the right server name and that it is SQL Server.  For security I chose Be made using the login's current security context.  If I read the documentation correctly, that means Windows authentication.  When I hit OK, I get the infamous Logon failed for user 'NT AUTHORITY\ANONYMOUS LOGON'

HELP...please.

TIA,

John

Execution plan "estimated number of rows" display value

$
0
0

hi,

1.execution plan for query "estimated number of rows" display 9.333. why is that

2. tried with trace QueryTraceOn 9130  and return 19614.

hope this is issue with index scan.

how to resolve this please 


Backup Job Failure Issue

$
0
0

Hope everybody is doing good.

Could you help me out to fix the following issue ?

we have created a maintenance plan followed with verify backup integrity for backing up the databases.

But the job is getting failed with the following error at times.

Error:

Executing the query "declare @backupSetId as int

select @backupSetId =..." failed with the following error: "The backup or restore was aborted.
VERIFY DATABASE is terminating abnormally.
A severe error occurred on the current command. The results, if any, should be discarded.".
Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or
connection not established correctly.

-----End---

surprisingly, after completion of backup for all databases the job is getting hung and throwing the above error when it is aborted.

your response on this is greatly appreciated.

How to know the detail information of all buffer pages (like the address, timestamp ...) for a database

$
0
0
I have kept searching for the answers of this problem on the internet. But I can only found the answers of getting the total number of pages for a database. What I want to know is to list the address and time stamp of all pages for a database. I think there might be a DMV which stores those information but I can not figure out which DMV it is. Anyone can help?  

SQL Server on Hyper-V performance issue

$
0
0

Hi,
We've switched to using Hyper-V as our primary virtualization engine for hosting VM's about 3-4 years ago (switching from VMWare) and haven't had any noticable issues since then.

But now a hosted customer noticed performance issues when running SQL-server on the virtualized Machines, I don't think this is a "new" problem but no one ever "complained" about performance so therefore we haven't done any real testing and measuring of this particular problem before.

When testing this on the SQL-server we are running a normal Select query selecting 1 000 000 rows from a table.

If the VM has 1 vCPU this Query takes about 15-17 seconds, but if we add processors (2,4,8 doesn't matter) it takes about 27-29 second, no other changes done.

We have tried just about anything we can think of to speed up the Query with multiple vCPU's, but no matter what we do we get the same result, 1 vCPU is always a lot faster than using more cpu's.

The VHDx files of the VM are placed on SSD disk in our SAN and we get good Iops (about 60-70 000) so there should be no problem there.

The SQL version is 2014 Standard with all hotfixes and patches applied, the database doesnt really seem to matter either since we have tested in several different db's. We also tried to move the VM to a new host where it was the only VM without luck.

Anyone seen the same problem and possibly have a solution or idea of what to do now??


_____________________________________ /Michael R

SQL Disk Dependency problem on SQL 2008 cluster including errors

$
0
0

Hi All,

I have a SQL 2008 cluster running with 2 nodes, and what I have recently noticed is that a snapshot creation code has been failing. I checked the cluster dependency property on the SQL instance

and I noticed that the dependency wasn’t set on the backup drive, I took SQL offline, set the dependency and then brought it back online and yet the create snapshot code doesn’t work.

Please note that the drive is a mount point.

Any ideas please

CREATE DATABASE [DBNAME] ON (NAME = [DBNAME], FILENAME = 'X:\BackupMount\Snapshot\DBNAME_Snapshot.ss') AS SNAPSHOT OF [DBNAME]; Msg 5184, Level 16, State 2, Line 1 Cannot use file 'X:\BackupMount\Snapshot\DBNAME_Snapshot.ss' for clustered server. Only

on formatted files on which the cluster resource of the server has a dependency can be used. Either the disk resource containing the file is not present in the cluster group or the cluster resource of the Sql Server does not have a dependency on it.

Error


Msg 5184,Level 16,State 2, Line 1

Cannot

usefile'X:\BackupMount\Snapshot\DBNAME_Snapshot.ss'forclusteredserver. Only formatted files on which the clusterresourceof theserver has a dependency can be used. Either the diskresource containing thefileisnot presentin the clustergroupor the clusterresourceof theSqlServer doesnot have a dependencyon it.

Cannot change SQL 2008 R2 Service account from local System to any account

$
0
0

Windows 7 64 Bit Developer Edition of SQL Server 2008 R2

Successfully changed SQL Server Agent, SQL Server Reporting Services, SQL  Analysis Services, SQL Server Integeration Services and SQL Full-Text Filter Daemon Launcher from Local System Account to Domain account.  Howerver,  I cannot change the SQL Server Account.  The SQL Server Configuration Manager generates the below error:

WMI Provider ERROR (in window title bar)

Big red X followed by "The parameter is incorrect. [0x80070057].

I have tried many things with no luck:

Tried using a different local administrator account

Tried putting the Domain account I want to change to in the local admin group

Tried adding the Domain account I want to change to in all of the SQL created local groups

I think im going to have to reinstall to change the account.  What up!@!!

 

-thanks for any help in advance.  Its probably something dumb i did or did not do.

 

 

 


scott
Viewing all 15872 articles
Browse latest View live


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