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

Help Needed with Linked Server Issue

$
0
0

Server 1 SQL2008R2

Server 2 SQL2014

I have been trying to set up a linked server and followed several posts to try and get it working. each time it fails.

When adding a record to Server 1 table, I have added a trigger to add that record to a table in server 2

I am at a total Loss as to what to do now

OLE DB provider "SQLNCLI10" for linked server "Serer2" returned message "No transaction is active.".

Msg 7391, Level 16, State 2, Procedure AddToSVR2, Line 18

The operation could not be performed because OLE DB provider "SQLNCLI10" for linked server "Server2" was unable to begin a distributed transaction.

(SERVER 1)

(Server 2)


Dont ask me .. i dont know


Index Rebuild operation error

$
0
0

While performing index rebuild operation I am getting below error. Please advise how to fix below error.

Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '-'.
Msg 319, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.

USE PROD_DB;

DECLARE @DatabaseName SYSNAME   = DB_NAME(),  @TableName VARCHAR(256)
DECLARE @FILLFACTOR INT = 90
DECLARE @DynamicSQL NVARCHAR(max) =
 'DECLARE curAllTablesInDB CURSOR FOR SELECT TABLE_SCHEMA +
 ''.'' + TABLE_NAME AS TABLENAME
 FROM ' + @DatabaseName + '.INFORMATION_SCHEMA.TABLES WHERE
 TABLE_TYPE = ''BASE TABLE'''

BEGIN
  EXEC sp_executeSQL @DynamicSQL  -- create tables cursor
  OPEN curAllTablesInDB
  FETCH NEXT FROM curAllTablesInDB INTO @TableName
  WHILE (@@FETCH_STATUS = 0)
  BEGIN
       SET @DynamicSQL = 'ALTER INDEX ALL ON ' + @TableName +
         ' REBUILD WITH (FILLFACTOR = ' + CONVERT(VARCHAR,@FILLFACTOR) + ')'
       PRINT @DynamicSQL
       -- ALTER INDEX ALL ON Purchasing.ShipMethod REBUILD WITH (FILLFACTOR = 85)
       EXEC sp_executeSQL @DynamicSQL
       FETCH NEXT FROM curAllTablesInDB INTO @TableName
   END   -- cursor WHILE
   CLOSE curAllTablesInDB
   DEALLOCATE curAllTablesInDB
END

Shrink tempdb automatically when disc contention

$
0
0

Hello All,

I wanted to Shrink tempdb automatically when there is disk contention, I am running below queries when we found tempdb full.


use tempdb;
go
checkpoint;
go
dbcc dropcleanbuffers;
go
dbcc freeproccache;
go
dbcc freesystemcache('ALL');
go
dbcc freesessioncache;
go


USE [tempdb]
GO
DBCC SHRINKDATABASE(N'tempdb' )
GO

I wanted to automate above script , it will execute only if there is disk contention.

I have SQL Server 2K8

Regards

ChetanV



sql server 2008 R2- Truncated 200GB table but disk space not released.

$
0
0

Hi,

SQL Server 2008 R2 database size - 250 GB

One of table having 200 GB and I have truncate that table but still database size is showing 250 GB.

I have tried shrink database and shrink file command but it is taking too much time.

Please suggest...

Thanks

Bijay Maurya

Tech Mahindra


Regards, Bijay Maurya

Schema level backup in sql server 2008 r2 onwards.

$
0
0

Dear All,

How to take schema level backup in sql server 2008r2 onwards.

"The target principal name is incorrent" error AFTER cumulative update Win10 KB3189866

$
0
0

Hi all!

1. 3 Machines that installed the update cannot connect to a remote SQL Server (2014 Express) residing on a Windows 2008 R2 Server when using Windows Authentication.

2. 1 Machine that did NOT install the update has NO PROBLEM connecting to the same server.

3. 1 of the 3 failing machines that uninstalled the update resolved the problem!

4. The message from SSMS trying to connect (Named Pipes, No SSPI) is "The target principal name is incorrect. Cannot generate SSPI context (Microsoft SQL Server)". !!?

5. All machines can ping the server successfully both by IP address AND by name.

6. All machines can connect to the server using SQL Authentication.

7. Trying to connect from one of the failing machines to another remote SQL Server (SQL Server 2008 R2 SP1 on a Windows 7 computer) with Windows Authentication, also fails with the same error message: "The target principal name is incorrect. Cannot generate SSPI context (Microsoft SQL Server)".

8. Connecting to the server as mentioned in (7) above with SQL Authentication works fine.

Report to Microsoft Connect:

https://connect.microsoft.com/SQLServer/feedback/details/3103373

If you have the same problem/error please upvote/comment on my report.

Thanks!

"The target principal name is incorrect" error AFTER cumulative update Win10 KB3189866

$
0
0

Hi all!

1. 3 Machines that installed the update cannot connect to a remote SQL Server (2014 Express) residing on a Windows 2008 R2 Server when using Windows Authentication.

2. 1 Machine that did NOT install the update has NO PROBLEM connecting to the same server.

3. 1 of the 3 failing machines that uninstalled the update resolved the problem!

4. The message from SSMS trying to connect (Named Pipes, No SSPI) is "The target principal name is incorrect. Cannot generate SSPI context (Microsoft SQL Server)". !!?

5. All machines can ping the server successfully both by IP address AND by name.

6. All machines can connect to the server using SQL Authentication.

7. Trying to connect from one of the failing machines to another remote SQL Server (SQL Server 2008 R2 SP1 on a Windows 7 computer) with Windows Authentication, also fails with the same error message: "The target principal name is incorrect. Cannot generate SSPI context (Microsoft SQL Server)".

8. Connecting to the server as mentioned in (7) above with SQL Authentication works fine.

Report to Microsoft Connect:

https://connect.microsoft.com/SQLServer/feedback/details/3103373

If you have the same problem/error please upvote/comment on my report.

Thanks!


Storing a PDF in SQL 2014

$
0
0
What is the best way to store a pdf in SQL

DBCC SHRINKFILE in SQL Server 2008 R2

$
0
0

Hi,

What is meaning of below commanrd in in SQL Server 2008 R2 ?

DBCC SHRINKFILE (N'ReportServer' , 500)


Regards, Bijay Maurya

SSIS 2014 Client unable to establish connection

$
0
0

Hello, I'm facing a strange issue and need some help, I have a .dtsx package that has a simple connection manager to a SQL Server 2014 database, if I run it on my local PC it works fine but if I copy the .dtsx to a Server (different than the DB Server) and try to run it on the server (filesystem run, using "dtexec /F mypackage.dtsx") I get the issue below:

"A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. 
SSL Provider: The client and server cannot communicate, because they do not possess a common algorithm.
Client unable to establish connection.
Encryption not supported on the client. (Microsoft SQL Server Native Client 11.0)"

The server where I'm trying to run it from has only SSIS installed and has the Native client 11.0 too. I am 99% sure the package itself is not the issue because if I run the SQL Server Import and Export Wizard on the server it gives me the exact same error on the first screen where it asks you for the source server name and db. Please help!

Thanks,

Creating Columnstore index on one table locks all DDL on any other table in the database

$
0
0

hi ... not sure if this is a SQL server issue (or maybe just a fact)

but we're developing a warehouse where two or three developers are working concurrently.

when developer 1 is creating say a CCI on table 1 developer 2 and 3 cannot create or alter any other table ?

is that the way it is because of the underlying sys table ?

or can this be changed 


eddy.a

The target principal name is incorrect. Cannot generate SSPI context.

$
0
0

Server, Windows 10 HOME 32 Bit, MS SQL Server 2014

Client, Windows 10 HOME 64 Bit

Everything was working fine, now all of a sudden I'm getting the above when I try and access the server from Visual Studio.

Almost everything I can find about it is DC/Active directory related.  I'm on Windows home, so no DC.

The only error I see in the event viewer is:

Error Schannel36882 None

That event is because of the self signed cert and is supposed to be ignorable. 

I tried switching to "SQL Server Authentication"

But now I get:

A connection was successfully established to the server, but then an error occurred during the pre-login handshake. 

I think an SQL update was part of the Visual Studio updates I installed yesterday and may be part of the problem.

Edit: After a reboot on the client I was able to "SQL Server Authentication" running. (Note: if you do this you will also need to enable SQL Server Authentication on the server and create a log in account.)

Still curious why I get the "Cannot generate SSPI context." all of a sudden.


John Fenton, MCC2011
Senior Programer Data Automation Systems




No . of Logins in SQL Server Database

$
0
0

Hi All,

I want to know how many users logged in to or accessed  my database in a given time frame.

I know that I can get the active users using sysprocesses but I have a requirement in which client is asking for the number of users using the database in a given time.

Any help will be appreciated.

Transactional backup every 60 min in Always On?

$
0
0

Hi there, I am just wondering if it is really necessary to do it every hour. We run VMWare with Always On. Our third-party backup tool is already copying the whole machines both primary and secondary. Apart or that, afaik, we always have a copy in the second node for the LDF aren't we adding more complexity, another unnecessary layer to our DR?

Thanks for sharing your thoughts,

ssms scripting error

$
0
0

i am using ssms 2016 vs a 2008 database. i get a scripting error message when attempting to modify or script an SP

when I use ssms 2014 it works with no problems. i have tried dropping and recreating the sp using 2016 and it still does not work

the message:

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

Script failed for StoredProcedure 'dbo.rashim_adv_search'.  (Microsoft.SqlServer.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=13.0.15800.18+((SSMS_Rel).160914-0312)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Script+StoredProcedure&LinkId=20476

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

Syntax error in TextHeader of StoredProcedure 'rashim_adv_search'. (Microsoft.SqlServer.Smo)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=13.0.15800.18+((SSMS_Rel).160914-0312)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&LinkId=20476

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

OK
------------------------------

the SP as scripted via 2014

USE [broadcasts]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		David Berlinger
-- Create date: 13 Sep 2011
-- Description:	rashim_adv_search
-- =============================================
create PROCEDURE [dbo].[rashim_adv_search]
(@channel_xml xml, @from date,@to date,@bi_xml xml,@edit_user int,
 @creation_name nvarchar(50),@perf_xml xml,@lyrist_xml xml,@composer_xml xml,
 @company nvarchar(50),@creation_type tinyint
)
AS
BEGIN

 declare @idoc int
 declare @chan table (channel_code tinyint)
 declare @bi table (broadcast_item int)
 declare @perf table (artist int)
 declare @lyrist table (artist int)
 declare @composer table (artist int)
 declare @edit_worker int

 if @edit_user is not null set @edit_worker=tashtit.dbo.get_worker_id_via_userid(2,@edit_user)
  set @creation_name= '%'+isnull(@creation_name,'')+'%'

 EXEC sp_xml_preparedocument @idoc OUTPUT, @channel_xml

   insert into @chan (channel_code )
     SELECT ch
            FROM       OPENXML (@idoc, '/root/r',1)
            WITH (	ch 	 tinyint)

  exec sp_xml_removedocument @idoc

  if @bi_xml is not null
    begin
      EXEC sp_xml_preparedocument @idoc OUTPUT, @bi_xml

      insert into @bi (broadcast_item )
        SELECT item
            FROM       OPENXML (@idoc, '/root/r',1)
            WITH (	item 	 int)

      exec sp_xml_removedocument @idoc
  end
  if @perf_xml is not null
  begin
     EXEC sp_xml_preparedocument @idoc OUTPUT, @perf_xml

     insert into @perf (artist )
        SELECT artist
            FROM       OPENXML (@idoc, '/root/r',1)
            WITH (	artist 	 int)

      exec sp_xml_removedocument @idoc
  end
  if @lyrist_xml is not null
  begin
       EXEC sp_xml_preparedocument @idoc OUTPUT, @lyrist_xml

       insert into @lyrist (artist )
         SELECT artist
            FROM       OPENXML (@idoc, '/root/r',1)
            WITH (	artist 	 int)

       exec sp_xml_removedocument @idoc
  end

  if @composer_xml is not null
  begin
       EXEC sp_xml_preparedocument @idoc OUTPUT, @composer_xml

      insert into @composer (artist )
         SELECT artist
            FROM       OPENXML (@idoc, '/root/r',1)
            WITH (	artist 	 int)

      exec sp_xml_removedocument @idoc
  end



SELECT distinct top 1001 'rash_adv' as rash_adv,
      dbo.schedules.schedule_code, dbo.schedules.schedule_date, dbo.schedules.start_date,
      dbo.schedules.title, dbo.rashim_titles.edit_worker,
      dbo.rashim_details.performance_code,
      creation_details_view.creation_name,
      creation_details_view.creation_name_heb, creation_details_view.creators,
      creation_details_view.main_performer, creation_details_view.recording_name,
      creation_details_view.main_performer_codes, dbo.rashim_details.item_num,
      recording_media_view.company,
      tashtit.dbo.get_users_name_via_workerid(dbo.rashim_titles.edit_worker) as edit_workername,
      tashtit.dbo.get_users_name_via_workerid(dbo.rashim_titles.edit_worker) as edit_username

FROM dbo.schedules INNER JOIN
    dbo.rashim_titles ON dbo.schedules.schedule_code = dbo.rashim_titles.schedule_code INNER JOIN
    dbo.rashim_details ON dbo.rashim_titles.rashim_code = dbo.rashim_details.rashim_code INNER JOIN
    dbo.creation_details_view ON
    dbo.rashim_details.performance_code = creation_details_view.performance_code LEFT OUTER JOIN
    dbo.recording_medias recording_media_view
    ON dbo.rashim_details.item_num = recording_media_view.device_num
  where schedules.channel_code in (select channel_code from @chan )
    and schedules.schedule_date between @from and @to
    and (@bi_xml is null or schedules.broadcast_item_code in (select broadcast_item from @bi))
    and (@edit_worker is null or dbo.rashim_titles.edit_worker=@edit_worker)
    and (dbo.creation_details_view.creation_type_code=@creation_type or @creation_type is null)
    and (creation_details_view.creation_name like @creation_name or
         creation_details_view.creation_name_heb like @creation_name or
		 @creation_name ='%%')
    and (@company is null or recording_media_view.company = @company)
    and (@perf_xml is null or creation_details_view.version_code in
                            (select version_code from dbo.version_artist_view
                              where artist_code in (select artist from @perf)))
    and (@lyrist_xml is null or creation_details_view.creation_code in
                            (select creation_code from dbo.creation_artist_view
                              where job_code in (1,11)
                                and artist_code in (select artist from @lyrist)))
    and (@composer_xml is null or creation_details_view.creation_code in
                            (select creation_code from dbo.creation_artist_view
                              where job_code in (2,11)
                                and artist_code in (select artist from @composer)))
    option(recompile)


END



???


Error on occurred when a procedure run

$
0
0

Facing a prob. when a procedure executing : "Logical consistence based Error ....."

Microsoft SQL server error:233

$
0
0

I am getting this error when connecting to sql. I cant get into my databases now- its pretty ugly.

 

"A connection was succesfulyl established with the server, but then an error occured during the login process.

(provider: Shared Memeory Provoder, error: 0 - No Process is on the other end of the pipe.)Microsoft SQL server error:233

 

Anyone who knows what is going on soem help would be much appreciated.

Mat

inplace Upgrade from 2008 R2 to 2014 SQL

$
0
0
Hi, I m trying to upgrade SQL server 2008 R2 to 2014 and stuck with it. the error log from bootstrap is not very helpful. Here is the error message, Anyone has come across similar error? Thanks!

Security Problem

$
0
0

Hi,

I encounter a security problem in SQL Server:

1. I install SQL Server 2008 R2 instance on Windows 7, with Windows Authentication.

2. I Login SQL Server Management Studio, with my current Windows account.

3. I go to "Security -> Roles"

4. Under sysadmin, I delete my own account by mistake.

5. Then after that, even I try to re-add my account, I will get "no permission" error.

6. I check sysadmin and find the only account is sa. But I don't know the password for sa since I have never set it during installation process(I choose WIndows Authentication, not SQL Server Authentication).

So in such a case, how can I re-obtain my sysadmin role?

Thanks

Query slow in client machine SSMS fast in server SSMS

$
0
0

Greetings All,

I have one query that run in server SSMS just need 26 secs but when run in my laptop SSMS need 11 minutes. Let me include the client statistics here

Server SSMS

Client Execution Time    14:34:41        
Query Profile Statistics            
  Number of INSERT, DELETE and UPDATE statements    0        0.0000
  Rows affected by INSERT, DELETE, or UPDATE statements    0        0.0000
  Number of SELECT statements     1        1.0000
  Rows returned by SELECT statements    493260        493260.0000
  Number of transactions     0        0.0000
Network Statistics            
  Number of server roundtrips    1        1.0000
  TDS packets sent from client    1        1.0000
  TDS packets received from server    48880        48880.0000
  Bytes sent from client    1242        1242.0000
  Bytes received from server    2.001887E+08        200188700.0000
Time Statistics            
  Client processing time    9062        9062.0000
  Total execution time    9063        9063.0000
  Wait time on server replies    1        1.0000

Laptop SSMS

Client Execution Time    14:28:38        
Query Profile Statistics            
  Number of INSERT, DELETE and UPDATE statements    0        0.0000
  Rows affected by INSERT, DELETE, or UPDATE statements    0        0.0000
  Number of SELECT statements     1        1.0000
  Rows returned by SELECT statements    493260        493260.0000
  Number of transactions     0        0.0000
Network Statistics            
  Number of server roundtrips    1        1.0000
  TDS packets sent from client    1        1.0000
  TDS packets received from server    74842        74842.0000
  Bytes sent from client    1242        1242.0000
  Bytes received from server    2.001887E+08        200188700.0000
Time Statistics            
  Client processing time    736908        736908.0000
  Total execution time    737367        737367.0000
  Wait time on server replies    459        459.0000

What is the reason will causing this? I m getting 490k rows from the server. Thank you very much.

Regards,

Justin Wong

Viewing all 12554 articles
Browse latest View live


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