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

Query over linked server responds with partial data when the spid on the remote server is killed

$
0
0

Local server is version 10.50.4000
Linked server is 9.0.5000

With the following stored procedure:
Create table #TMP
    (
        [ID] int NOT NULL,
        [SKU] [varchar](50) NOT NULL,
        ...
    )
    INSERT INTO #TMP
    SELECT
        [Siteid]
     ,[ITEM]
    
    FROM LinkedServer.db.dbo.v_ViewOnLinkedServer WITH (NOLOCK)
    
    PRINT 'Inserted'
    
    DELETE LocalTable
    WHERE SKU NOT IN (SELECT SKU FROM #TMP)

The spid on the remote server was killed and the query inserted into the temp table just a third of the records - causing the other 2 thirds to be deleted

What was expected:
The cross sever query should have been an Atomic operation - if part of it failed then all of it should have failed.

We ran many tests over and over (20 +) and got variable results - 

most times it retrieves thousands of rows then failed cleanly when the spid was killed.

however about 5% of the time  the query returned as if it had read all of its results and continued on with the next stamtet as if nothing happend


An error occurred while executing batch. Error message is: Exception of type 'System.OutOfMemoryException' was thrown.

$
0
0
I am getting this error repeatedly on SQL Server 2008 on Windows machine when i run a simple query which involves close to ~ 10 million records.
select sum(a.test) from (select COUNT(*) as test from xf.dbo.sec_mthprc s1 group by gvkey, datadate) a

Technical Data:
   Sql Server 2008 : 2009-07-29 03:13:16.280 Server       Microsoft SQL Server 2008 (SP1) - 10.0.2531.0 (X64)
                             Mar 29 2009 10:11:52
                             Copyright (c) 1988-2008 Microsoft Corporation
                             Developer Edition (64-bit) on Windows NT 6.0 <X64> (Build 6001: Service Pack 1)
   Microsoft Windows 2008 Standard Edition x64 with 16 GB RAM and 2 quad-core processors

Running SQL 2008 R2 but server showing up as sql 2005 (9.0.4035)

$
0
0

I have installed and run 2008 R2 for some time--no problems. use as backend for VS2008 code

recently I tried to restore one of my developer databases with a backup from a production server running 2008.

gave me error messages about incompatible media family--tracked down that problem and discovered that even though I installed and thought I was running 2008 on my developer box, @@version gives 9.0.4035.  but 2008 R2 is installed and management studio gives version 10.50.1617.

now I need to import data from the 2008 to what I thought was my 2008 but is really 2005.  I tried scripting but HUGE file.  until I can get some free time to uninstall and try to install sql 2008 again, any ideas for a temp work around. 

is there a way to upgrade this 2005 instance inside of my 2008 installation to 2008 structure. can this thing happen or did I have a bad installation. only thinig I can think of is that in the past I might have backed up a 2005 database from another machine and restored it here but not sure how that could result in this.

another theory-when I installed Visual Studio 2008, it might have installed 2005 SQL Express.  then I installed SQL 2008.  probably should have done it the other way around, i'm thinking

any advice is appreciated

thanks

dale

Update PDF file in FileTable

$
0
0

Hi-
I'm new to working with FileTables and am wondering if the following code (which saves annotations to a PDF file in the FileTable with changes that are made through the PDF control) makes sense. My save results are mixed while using the PDF control, depending upon the PDF file that is loaded. If a save is successful, the PDF control will load the PDF file with the annoatations, but the PDF file will not open in Adobe Acrobat (file corruption error is reported).

When using the provided PDFTron sample PDF control project with a file loaded from the file system, no errors are reported when saving annotations to the PDF file, and the changes can be viewed using Adobe Acrobat.

I'm wondering whether my code is generally appropriate, or if I'm going about this all wrong.

        'Create a connection to the database
        Dim ConStr As String
        ConStr = MyAppConnString
        Dim con As New SqlConnection(ConStr)
        con.Open()

        Dim sqlCommand As New SqlCommand()

        ' Set Command text to stored procedure name
        With sqlCommand
            sqlCommand.Parameters.Clear()
            .CommandText = "RetrieveDocument"
            ' Set the command type to Stored procedure
            .CommandType = CommandType.StoredProcedure
            ' Add parameter/s to the command. Depends on the Stored procedure
            .Parameters.Add("@SelectedNode", SqlDbType.NVarChar, 128).Value = myTag
            'add the conection to the command
            .Connection = con
        End With

        Dim filePath As String = CStr(sqlCommand.ExecuteScalar())

        'Obtain a Transaction Context
        Dim transaction As SqlTransaction = con.BeginTransaction("ItemTran")
        sqlCommand.Transaction = transaction

        ' Set Command text to stored procedure name
        With sqlCommand
            sqlCommand.Parameters.Clear()
            .CommandText = "tContext"
            ' Set the command type to Stored procedure
            .CommandType = CommandType.StoredProcedure
            .Connection = con
        End With

        Dim txContext As Byte() = CType(sqlCommand.ExecuteScalar(), Byte())

        'Open and read file using SqlFileStream Class
        Dim sqlFileStream As New SqlTypes.SqlFileStream(filePath, txContext, FileAccess.ReadWrite)
        Dim buffer As Byte() = New Byte(CInt(sqlFileStream.Length)) {}

        'Bind the image data to an image control
        Dim ms As MemoryStream = New MemoryStream(buffer)

        _pdfdoc.Lock()
        Try
            _pdfdoc.Save(ms, SDF.SDFDoc.SaveOptions.e_incremental)
        Catch ex As Exception
            MessageBox.Show(ex.ToString(), "Error during the Save")
        End Try
        _pdfdoc.Unlock()

        sqlFileStream.Write(buffer, 0, buffer.Length)

        'Cleanup
        sqlFileStream.Close()
        sqlCommand.Transaction.Commit()
        con.Close()

Thank you,

Matt

Issues with reporting percent log space used, between DMV and DBCC

$
0
0
Using SQL Server 2012 SE 11.0.2100, I am getting two different sets of values when querying for log space between the DMV and the DBCC command. 

Querying using the DMV.

select instance_name as DBName, cntr_value as PercentLogUsed from sys.dm_os_performance_counters where counter_name = 'Percent Log Used' and instance_name <> '_Total' and instance_name <> 'mssqlsystemresource' and instance_name <> 'model' order by cntr_value desc

The results that I get from using this DMV are about 10% off from the results that I get when I use dbcc.

DBCC SQLPERF(logspace)

Why is this?




User cannot access database over VPN - database not accessible - sql authentication SSMS

$
0
0

I haven't been able to find this scenario or a solution from searching.  Any help is greatly appreciated.

Using Sql Server Management Studio, I can connect to the database engine. 

Inside the office -- I can see the list of all the database instances.  When I try to expand any of the instances, I can connect to the database and see all the items I have access to, like Tables.

Outside the office over VPN -- I can see the instances, but I cannot connect to it.  I receive the usual error: 

The database [fill in the database name here] is not accessible. (ObjectExplorer)

If I look at the details of the error, it has this:

The database [instance name] is not accessible. (ObjectExplorer)

------------------------------
Program Location:

   at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.DatabaseNavigableItem.get_CanGetChildren()
   at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.NavigableItem.GetChildren(IGetChildrenRequest request)
   at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.ExplorerHierarchyNode.BuildChildren(WaitHandle quitEvent)

If I disconnect from the database engine, then reconnect with other user credentials, I can access everything.

In summary:  the same user can access within the offce, but not over VPN;  I can use a different user and access both ways just fine.

I can see the server properties and configurations and the permissions for the user I'm trying to use.  CONNECT SQL and VIEW ANY DATABASE are effective.

What may be wrong here?


Unable to connect from SQL server 2008(Sp2) version client to SQL Server2012(SP1)

$
0
0

Our requirement is to connect to dtatabse server from .net application sitting on application server to invoke and run the sql agent job in database server.

But there is different version of SQL server installed on both the application and databse server.

Database server(sql server 2012) is higher version of sql server than the application server(sql server 2008)

We have two servers:

1) Application server- with SQL server 2008(SP2) where our client window application will be running.

2) Database server- with SQL server 2012(SP1) where our sql agent job will be running .

The application server cannot be upgraded to new version of sql server as presently the client application will not support the latter version of sql server. It is compatible only with SQL server 2008(SP2) version.

when we tried to connect to database server from application server using managemet studio it gives the message "Index was out of bounds of array(microsoft.sqlserver.smo)", but still it allows me to connect to database server instance and run our job using the sp_start_job <'job_name'>

From our client windows application which sits on application server(with sql server 2008) we try to connect to database server using connection string in .net code and tries to execute the job sitting on the databse server(sql server 2012) by calling the same sp in .net code, but the log file gives connection error, and hence application is not allowed to establish connection to databse server with Microsoft sql Client 10.0.

Please assist on the above issue.

Thai Buddhist Calender for SQL Server 2008 R2


SQL Server Target Memory

$
0
0

Hi All

I have few SQL 2008 R2 32bits on Server 2008 32bits, I leave all the min and max memory setting to default ( i know it's a bad practise). I start up all the sql servers and check their target memory... and found that all in different values..

how could this happened?Will it affect the performance ?Some server has physical 2GB and some has 4GB memory 

database migration from SQL Server 2008 (enterprise version) to SQL Server 2012 (enterprise version)

$
0
0

Can I restore database backup file from SQL Server 2008 (enterprise version) to SQL Server 2012 (enterprise version)?

Does there any known issues?

Any tips.

Regards,

Rajiv Shah

database size in year

$
0
0

Hi,

I want to know the increase in database size yearly

Please help

Sqlserver high memory utilization

$
0
0

Dear All,

We have a server sql server 2008 r2 64 bit(enterprise edition) on windows 2008 64bit(enterprise).

Our ram size is 16gb.In this sql is using 10gb. Due to this we are always reaching memory threshold to 97%.

We cannot enable AWE since it is a 64bit server.How to set max memory settings in this server.If we set this is there any impact in future.

Thanks in advance.

calculate table size of many tables

$
0
0

Hi,

I want to calculate the size of multiple tables in one shot. Please suggest

Regards

Shrinkfile exhausting space in transaction log for relatively small amount of data and can't figure out why?

$
0
0
I have multiple file database where the ndf file 9  is 134g in size but 122g of it is free due to a massive amount of table deletions of histrical tables.   The last 12g is most recently created tables  and I have a  two copies of this database.    I have tried running the SQL SERVER Managment Studio  menus and telling it to reorganize the pages  looking to move the 12g to the front of the file and it the shrink failed  because it filled up a 49g transaction log file.     On the second copy of the database I used the command DBCC (9,1)  to shrink the file in a query window.   On this instance the log was only 25g in size but I had done some testing on experimental databases of large allocations where huge amounts of data was deleted and only 12g left at the end and it barely touched the transaction log file so I thought I was safe.   Again I exhausted the transaction log file.   I am baffled as to why this operation is hitting the transaction log file so hard and  if I have to make a large transaction log file, just how large must it be? 

Cursor and Memory?

$
0
0

I have a strange issue,

When I create a cursor to go and do some work on all my DBs, sometimes it does the work only for the first few and then stops with no output.

i.e. I have a job that runs a cursor on all my DBs and does a reindex on each of them, using a script I wrote for determining which reindex options should be used for each table.

I have very big DBs (all together 5TB), and the number of DBs are dozens.

If I replace the inner script of the cursor with a print of the DB name or any other light process, it runs on all the DBs, but when running it on a heavy job, will stop in the middle.

The above cursor runs as a step in a job (inside a maintenance plan by SSIS).

Today I was searching for a string in all my tables all over the server, so I created a dynamic script to select top 1 where column like ‘%string%’ on all my tables , and it ran only a few of them, the above was ran from the SSMS query window. So I copied the script again on the same window (meaning still on the same session) and had first cursor running on all DBs where the name < I and then again created the same cursor (same name) for all DBs where name > I and it completed the work.

I assume it is something to do with memory or other resource.

Do you know what can I do to have it run over all the DBs in the same cursor?


Sql server taking high memory

$
0
0

Dear All,

We have a server sql server 2008 r2 64 bit(enterprise edition) on windows 2008 64bit(enterprise).

Our ram size is 16gb.In this sql is using 10gb. Due to this we are always reaching memory threshold to 97%.

We cannot enable AWE since it is a 64bit server.How to set max memory settings in this server.If we set this is there any impact in future.

Thanks in advance.

What is the data stream type for SQL VDI backup.

$
0
0

HI 

Can any body tell me ,What is the data stream type used for SQL VDI backup ?

I also wanted to know if the tape format is a MTF format ?

Is the VDI stream also contains Volume,folder and file descriptor blocks for data base backup ?if yes what are these values for SQL server.

Thanks

Arun

How SQL backup data is written on VDI device in case of the database having multiple data files.

$
0
0

What is the sequence maintained w.r.t data stream for  SQL database backup having multiple data files..

Is it serialized as per the number of data files or something different?

Log shipping Configuration with Net backup solution

$
0
0

Hi,

i have 1 production server where i have sql 2005 64 bit is installed ,i have configured NET backup job for FUll @ night, Diff Every 3 Hours , and log backup every one Hour.

Now my company have a plan to configure Logshipping on above server.

before going to deploy i have some imp quetions  .

1) if i configure log shipping will it impact current net backpup job.

2) At night i take full backup through net backup , after taking full backup my log shipping will continue without inconsistency of data ??

3)  While Taking transaction log backup there is one option in net backup is,take transaction log backup without truncating log

      . IF i follow this condition and configure my log shipping will it work ??? and will it truncate the log file in prod server ??

Moreover , could you please tell me the solution to configure Log shipping on top of net backup job. 

 

Thanks in advance .

Nido

 

Linked Sever (Linking MySQL To SQL Server)

$
0
0

Hello Gurus,

What are the possible options available (and if possible the steps) to create a linked server. I use SQL Server and I want to link MySQL to my server.

Regards,


ebro

Viewing all 15889 articles
Browse latest View live


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