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

Comparision Merge clause vs If not exists

$
0
0

Hi Team,

There exits various stored procedures, wherein developer has used if exists then update and if not then inserted records.

I would like to know, what is good option, considering with the fact that, stored procedure must be optimized and need to consume less resources.

Thanks  


how to pass values with comma to comma seperated param in sp

$
0
0

hi all,

 i have one sp which has param name as cordinatorname varchar(max)

in where condition of my sp i passed as

coordinator=(coordinatorname in (select ltrim(rtrim(value)) from dbo.fnSPLIT(@coordinatorname,',')))

but now my promblm is for @coordinatorname i have values as 'coorcinator1', 'coordinato2,inc'

so when my ssrs report taking these values as multiselect, comma seperated coordinator2,inc also has comma already

how to get this solved. please help me..


lucky

Linked Server - Getting Error when performing Cross Instance Query with joins

$
0
0

Hi Guys,

I've successfully created a Linked Server that connects a local DB Engine with another DB Engine through an ip over an extranet. I am able to run simple Select statement queries on the Local DB Engine and get results from the linked server. However when attempting to perform more complex queries that join tables from the linked server with tables from the local DB server, I get the following error message after several minutes of execution:

OLE DB provider "SQLNCLI11" for linked server "<ip of Linked Server>" returned message "Protocol error in TDS stream".

OLE DB provider "SQLNCLI11" for linked server "<ip of Linked Server>" returned message "Communication link failure".

Msg -1, Level 16, State 1, Line 0

Session Provider: Physical connection is not usable [xFFFFFFFF].

OLE DB provider "SQLNCLI11" for linked server "<ip of Linked Server>" returned message "Communication link failure".

Msg -1, Level 16, State 1, Line 0

Session Provider: Physical connection is not usable [xFFFFFFFF].

OLE DB provider "SQLNCLI11" for linked server "<ip of Linked Server>" returned message "Communication link failure".

Msg 10054, Level 16, State 1, Line 0

TCP Provider: An existing connection was forcibly closed by the remote host.

Grateful if you could advise what may be causing this issue and how I can resolve it. I've read on Distributed Transactions but I understand that it only applies to manipulation statements?

Both are SQL servers. Linked Server is SQL2008R2 if not mistaken. Local DB Engine is SQL2014.


Thanks and Regards,

Rhyan.

SP2 CU5

$
0
0

Hi,

We are using SQL Server 2012 SP2 CU2. As of now we dont have any issues, but for a pro active approach, can I install CU5 based on the below Fixes which are included in CU5.

1. FIX: Performance issue occurs when you use sqlncli11.dll ODBC driver to access SQL Server in an application.

2. FIX: Complex parallel query does not respond in SQL Server 2012 or SQL Server 2014

3.  FIX: Rollback recovery on a snapshot fails when you run DBCC CHECKDB and then SQL Server shuts down unexpectedly.

Thanks,

FIX: Rollback recovery on a snapshot fails when you run DBCC CHECKDB and then SQL Server shuts down unexpectedly




SQL Server 2008 R2 - Linked Server Access to Sybase - Inconsistent Results

$
0
0

Good Afternoon All,

Thanks for stopping by this question.  I'm experiencing strange issues when executing queries from a SQL Server 2008 R2 server to a SYBASE Database.

The landscape and situation:

Here are the results when running @@Version for both MS SQL Server and the SYBASE DB:

MS SQL Server:

Microsoft SQL Server 2008 (SP3) - 10.0.5846.0 (X64)   Aug 26 2013 09:39:36   Copyright (c) 1988-2008 Microsoft Corporation  Standard Edition (64-bit) on Windows NT 6.0 <X64> (Build 6001: Service Pack 1) 

SYBASE DB:

Adaptive Server Enterprise/12.5.3/EBF 12455 ESD#2/P/Sun_svr4/OS 5.8/ase1253/1904/64-bit/FBO/Wed Mar 23 03:04:04 2005


The relevant SYBASE driver has been installed successfully (using the SDK).
I have created an ODBC entry in the System DNS Admin area.  When testing the connection the results aresuccessful.
I have successfully created a "Linked Server" in SQL Server.  When testing the connection the results aresuccessful.

Here is where it gets strange.  We normally use OPENQUERY to query remote non MS SQL Server databases.

SELECT
*
FROM
OPENQUERY(NAME_OF_LINKED_SERVER,
'
EXECUTE sp_name_of_sp
@filter_list = ''1022484'',
'
) AS A

However this never works with this Sybase database - for simple SELECTs or for execution of stored procedures.  The error message is:

"The OLE DB provider "MSDASQL" for linked server "NAME_OF_LINKED_SERVER" indicates that either the object has no columns or the current user does not have permissions on that object."

However when I use EXECUTE AT there is slightly more success.  For example:

EXECUTE
('EXECUTE sp_name_of_sp
@filter_list = ''1022484'',
') AT NAME_OF_LINKED_SERVER

I can successfully run some SELECT queries and Execution of Stored Procedures - howeversome of there are some incorrect.  For example executing a particular stored procedure should return 5000 rows - but when using EXECUTE AT only 2 rows are shown.  Other stored procedures on this same connection return thousands of rows with no problem.

As part of the testing I've used the ASE isql client on the remote server (The same server that's running MS MSQL Server - so using the same ODBC connection and driver) and the results using the client are perfect.  This leads me to suspect the MS SQL Server Management Studio is somehow handling the connection incorrectly.

Does anyone have any suggestions to make this work using OPENQUERY or EXECUTE AT (or any other method)?

Many Thanks in advance,
UnoT

Licensing of a Test SQL Server

$
0
0

Hi,

My question is regarding the use of SQL in a Development Environment. We have a VL Agreement. We have a Historical server using SQL in a 2 server cluster with a SAN. We purchased a SQL 2012 Standard Server for each server plus CAL's for all devices and users. For testing, a single server with local storage is used to develop and test changes before changing the production cluster. We have 2 Developers that will use the test server and 2 Developer Licenses were purchased. We used the production version of the SQL media to create the test server instead of the Dev version of the media. Are we compliant?

Move CMS to another SQL Server instance

$
0
0

Hi Gurus,

I want to move CMS to another SQL Server instance in the same box as previous SQL Server but with different instance. Is it possible to do that? Thank you.

kind regards,

Maliq

SQL2008 how to open .sqlaudit file

$
0
0

Hi everyone,

I created sqlserver audit specification which should audit events to a file. However, now I want to open it and review the file and I do not know how to open it or where to import it. Any ideas?

Thanks in advance,

Kal


Win2003r2 connecting to win2012 with SQL2012r2 Cluster - issue

$
0
0

Dear TechNet members,

i have a issue which i cannot find any solution on, so trying my luck here :-)

I have a couple of Windows 2003 r2 Terminal Services servers where my application is connecting today to a 2-node Clustered Windows 2008r2 with SQL 2008r2 and working fine..

And then i have made a couple of new Windows 2012 R2 Terminal Servers and a 2-node Windows 2012 r2 with SQL 2012r2 on it.

My problem is that i cannot connect from my application on Windows 2003 r2 to the clustered new SQL 2012r2 server,

and get this issue:

"SQL State:1, SQL Error Code: -1, Level: 16, Procedure: , Line: 0
SQL Server Network Interface: Error Locating Server/Instance Specified [xFFFFFFF]"

however - my application Works Again on second attempt! and then suddenly it does not Work and then suddenly it Works...

this problem does not happend from a Windows Server 2012 Terminal Server running same application toward the clustered SQL 2012r2 Server, is it compatibility issue from win2k3 to SQL12r2? any fix?

Another strange thing that i have noticed: if i create a None-clustered Windows 2012 r2 with SQL2012r2 (same ISO's) and same instance name "SQL01" (none default) so it looks like the clustered setup but in a none clustered mode then
my application Works fine from all Windows 2003r2 terminal servers connecting to it.

So it seems like issue happens as soon as i enable "clustered services with SQL2012r2" on Windows 2012r2 and my application connecting from Windows 2003r2 Terminal Server.

Obs. i have installed latest SQL native client on win2003r2 servers which is SQL2008r2 native client, but still problems..

any idea?

set maximum server memory by using sql scripts

$
0
0

Dear all

How to set maximum server memory by using sql scripts in sql server 2014? Thx a lot

Best regards,

Wallace


change sql server 2014 server name

$
0
0

Hi

This works on sql 2008 r2, but not on sql server 2014

sp_dropserver 'old_server'
---------

Msg 15015, Level 16, State 1, Procedure sp_dropserver, Line 42
The server 'old_server' does not exist. Use sp_helpserver to show available servers.

---------

sp_addserver 'new_server',local

---------

Msg 15028, Level 16, State 1, Procedure sp_addserver, Line 74
The server 'new_server' already exists.

Connectivity: Error 10054 An existing connection was forcibly closed by the remote host

$
0
0

This is a SQL 2008 R2 server.  I am attempting the connection from SSMS.  Neither windows nor sql authenication works.  However, i can connect using sqlcmd.  Also ODBC driver 'Test Connection' works.  My application (which is what i really want) doesn't work either.

There isn't anything in the ERRORLOG.  I have checked ring buffers and the ssat tool on codeplex.  I can't figure this out.

ideas/

thanks


-- dan http://dnhlmssql.blogspot.com/

Run Rebuild Index Task daily on database but about 77 tables still highly fragmented over 80% !!!

$
0
0

Hello everyone

On our particular database server, we run the Rebuild Index Task (Using classic Maintenance Plan Designer) every night. Running the  script below, I saw that about 77 tables had an avg_fragmentation_in_percentage between 80% and 99% !!

SELECT OBJECT_NAME(ind.OBJECT_ID) AS TableName,
ind.name AS IndexName, indexstats.index_type_desc AS IndexType,
indexstats.avg_fragmentation_in_percent
FROM sys.dm_db_index_physical_stats(DB_ID(), NULL, NULL, NULL, NULL) indexstats
INNER JOIN sys.indexes ind
ON ind.object_id = indexstats.object_id
AND ind.index_id = indexstats.index_id
WHERE indexstats.avg_fragmentation_in_percent > 30--You can specify the percent as you want
ORDER BY indexstats.avg_fragmentation_in_percent DESC

I dont understand why these tables are highly fragmented after a daily index rebuild! Unless the users are doing heavy inserts/updates/deletes during the day.

Anyone has an idea of the possible causes of these results??

Thank you all in advance


Prevent User to backup from Database

$
0
0

Hi,

We have a user with read,write and execute permissions.

But this user with is used by a windows application,Is able to backup on the Database server(On C:\ drive).

How can I prevent it to backup on the server.

Regards

Attention All SS DBE Gurus! Time to SPRING Into Action!

$
0
0

April fools out of the way, now let's find an April genius!

The name "April" is derived from the Latin verb "aperire", meaning "to open", as it is the season when trees, flowers AND MINDS start to open! And.. I can't wait to OPEN and read this month's community contributions! (groan, tenuous link!)

Things are indeed heating up around TechNet. The Wiki has become a shining example of what the community has to offer, and talent is SPRINGING FORTH from all corners of our garden of knowledge. 

If you can find the time to enrich us with your latest revelations, or some fascinating facts, then not only will you build up a profile and name for yourself within the gaze of Microsoft's very own glitterati, but you will be adding pages to the most respected source for Microsoft knowledge base articles. This could not only boost your career, but would benefit generations to come!

So don't be an April fool. Please realise the potential of this platform, realise where we are going, and join us in growing this community, learning more about you, and opening the minds of others!

All you have to do is add an article to TechNet Wiki from your own specialist field. Something that fits into one of the categories listed on the submissions page. Copy in your own blog posts, a forum solution, a white paper, or just something you had to solve for your own day's work today.

Drop us some nifty knowledge, or superb snippets, and become MICROSOFT TECHNOLOGY GURU OF THE MONTH!

This is an official Microsoft TechNet recognition, where people such as yourselves can truly get noticed!

HOW TO WIN

1) Please copy over your Microsoft technical solutions and revelations toTechNet Wiki.

2) Add a link to it on THIS WIKI COMPETITION PAGE (so we know you've contributed)

3) Every month, we will highlight your contributions, and select a "Guru of the Month" in each technology.

If you win, we will sing your praises in blogs and forums, similar to the weekly contributor awards. Once "on our radar" and making your mark, you will probably be interviewed for your greatness, and maybe eventually even invited into other inner TechNet/MSDN circles!

Winning this award in your favoured technology will help us learn the active members in each community.

Feel free to ask any questions below.

More about TechNet Guru Awards

Thanks in advance!
Pete Laker


#PEJL
Got any nice code? If you invest time in coding an elegant, novel or impressive answer on MSDN forums, why not copy it over toTechNet Wiki, for future generations to benefit from! You'll never get archived again, and you could win weekly awards!

Have you got what it takes o become this month's TechNet Technical Guru? Join a long list of well known community big hitters, show your knowledge and prowess in your favoured technologies!


Isnumeric

$
0
0

This is my first time when I review code with Isnumeric and trim. can anyone tell me how to interpret or what the following query would return? here is the query

isnumeric(left(ltrim(rtrim(cd.DialedNum)), 1))+ isnumeric(right(left(ltrim(rtrim(cd.DialedNum)), 2), 1))+isnumeric(right(left(ltrim(rtrim(cd.DialedNum)), 3), 1)))

thank you

How to script out linked in servers from sql 7.0

$
0
0
Can someone help me with the syntax of scripting out the linked server. Thanks

need to reboot/restart service after setting max server memory

$
0
0

Dear all,

After I have set the maximum sql server memory in sql server 2014 using sp_configure, do I need to reboot whole server or restart sql service?

Thanks and regards,
Wallace


SQL Agent - Error Authenticating Proxy

$
0
0

I am having an issue when scheduling an SSIS package on a Production environment (via SQL Agent, utilizing a Credential/Proxy). I have worked through the steps below in a Test environment and have not had any problems. Here's what I've done in Production (on a SQL Server 2008 R2 non-clustered environment):

- Copied SSIS package to file system (NTFS permissions are set properly)

- Created a Credential and Proxy (for a Windows user)

- Created SQL Agent job to execute the SSIS package

- Executed the job and receive the following error: 

"Unable to start execution of step 1 (reason: Error authenticating proxy DOMAIN/user, system error: Logon failure: unknown user name or bad password.).  The step failed."

Can someone help me work through this? I have tested the process above with a blank SSIS package, so I know it has nothing to do with access to the source systems. The issue resides specifically on the SQL Server box that is running SSIS and SQL Agent.

I have done some reading and found the following:

- Delegate permissions to SQL Agent account...

- Provide "Log on as a batch job" permissions to AD user

- Install a KB to fix...

Not sure what to puruse at this point. Also, the Job will run just fine using the SQL Agent service account; however, I need to run this user as a different account.

Please advise.


SCOPE_IDENTITY() blocking

$
0
0

First, some background....  Long-standing system, multiple applications and web apps communicating with SQL Server through a farm of load-balanced app servers.  The app servers are running a common "business object" that we refer to as the data-source factory (DSF, for short), it's purpose is to translate object calls into database queries (i.e., a client record from the database becomes a "Client" object with various attributes representing values from the database).  This system has been in existence for several years, and began life running against SQL Server 7, upgraded to 2000, 2005, and for the past year, 2008 R2.  At any given point in time, there will be 400-500 connections to the database, any number of which can be doing work.  Server is not taxed,  48 cores, 512GB RAM, no performance issues of any kind.

From the beginning, we've seen a rare issue (2-3 times a year) where we'll suddenly have a handful of SPIDs start blocking, each claiming to be running "SELECT SCOPE_IDENTITY()".  If ignored, more and more SPIDs will exhibit the same behaviour, to the point where we've seen 200 or more, all blocking, all waiting on SCOPE_IDENTITY().  Often, attempting to kill the offending SPIDs is unsuccessful, as they are immediately respawned, presumably by our DSF.  Multiple attempts to kill those SPIDs is sometimes effective, but on occasion we are forced to restart the DSF's.

Trace log analysis of these incidents has not revealed a common table or query, the issue seems to affect all inserts into all tables.  Of particular interest, "wait_type" and "wait_resource" for these offending SPIDs are both reported as NULL.

For the first time in over a year (since upgrading to 2008 R2), this "event" occurred again this morning.  I'm tired of not being able to explain it, but I don't know where else to look, I've poked into every dark corner of SQL Server that I know to poke, and I've found nothing.  I'm not convinced that this is a SQL Server problem, I think it's something within our DSF, but I don't know how to prove (or disprove) that theory.

Suggestions?  Web searches for "SCOPE_IDENTITY blocking" have come up empty, reaffirming my belief that this is not a SQL issue, but something unique to our app.

Below is a snippet from my blocking log for this morning's occurrence, showing the first two blockers.  Within 10 minutes, there were over 50 blocking SPIDs, all waiting on SCOPE_IDENTITY():

********** Start time: 28 Dec 2011 05:11:00:427 ********** [SQLSTATE 01000]
session_id                      blocker                                                                                              status                         wait_type                                                        wait_resource                                                wait_time   command                          cpu_time    logical_reads        memory_usage login_time                     last_request_begin_time        last_request_end_time          client_net_address                       net_transport                            database_id
------------------------------- ------- -------------------- -------------------- -------------------------------------------------- ------------------------------ ---------------------------------------------------------------- ------------------------------------------------------------ ----------- -------------------------------- ----------- -------------------- ------------ ------------------------------ ------------------------------ ------------------------------ ---------------------------------------- ---------------------------------------- -----------
320*                            0       a_web2               10.25.246.25                                                            sleeping                       (null)                                                           (null)                                                       (null)      (null)                           1724659     40185412             2            27 Dec 2011 18:42:57:260       28 Dec 2011 05:10:19:420       28 Dec 2011 05:10:19:420       10.25.246.25                             TCP                                      (null)
564*                            0       a_web2               10.25.246.25                                                            sleeping                       (null)                                                           (null)                                                       (null)      (null)                           2010        22632                2            28 Dec 2011 05:10:31:830       28 Dec 2011 05:10:58:360       28 Dec 2011 05:10:58:360       10.25.246.25                             TCP                                      (null)
169                             564     a_vts                10.25.246.24                                                            running                        LCK_M_U                                                          KEY: 6:395455534989312 (34ca69ce595f)                        664         UPDATE                           873         55748                2            28 Dec 2011 05:08:49:543       28 Dec 2011 05:10:59:810       28 Dec 2011 05:10:57:527       10.25.246.24                             TCP                                      6
514                             320     a_vts                10.25.246.20                                                            running                        LCK_M_U                                                          KEY: 6:72057594146652160 (86c97ce8fc81)                      41210       UPDATE                           16746       662206               2            28 Dec 2011 02:06:20:723       28 Dec 2011 05:10:19:230       28 Dec 2011 05:10:19:223       10.25.246.20                             TCP                                      6
session_id blocker resource_type        resource_subtype               resource_database_id resource_associated_entity_id request_mode                                                 database_name        object_name                                        resource_description
---------- ------- -------------------- ------------------------------ -------------------- ----------------------------- ------------------------------------------------------------ -------------------- -------------------------------------------------- ----------------------------------------------
514        320     KEY                                                 6                    72057594146652160             U                                                            Vue                  (null)                                             (86c97ce8fc81)
169        564     KEY                                                 6                    395455534989312               U                                                            Vue                  (null)                                             (34ca69ce595f)

---------------------------------------
***** session_id=320 *****

SELECT SCOPE_IDENTITY()

***** session_id=564 *****

SELECT SCOPE_IDENTITY()

Blocking Time = 0:41 [SQLSTATE 01000]


Viewing all 12963 articles
Browse latest View live


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