sql-server

ASP.Net - C# - SQL Server - Refreshing cached DataTable with only records that have changed.

I have a large DataTable cached in my web app that is the result of a complex query that returns a large data set. Whilst this data table is cached the query that runs to "refresh" this cache still takes a long time, largely due to the sheer amount of data being returned. In order to speed this up I am considering implementing a timesta...

help required with Sql query

I have a problem , got three Tables Table A ID Employee 1 1 2 2 3 3 Table B Id EMployee HoursWorked HoursCode 1 1 10 Basic Hours 2 1 20 Holiday Pay 3 2 10 ...

comparing the values of two columns in a table in two different database in sql server

i have 2 datbases A and B with tables AC and BD.table AC has a column ACcol and BD table has a column BDcol. i want to move all the records in ACcol to BDcol with ACcol='admin'. can anyone help me in doing this? ...

Connecting to SQL Server (from Ubuntu): [RubyODBC] Cannot allocate SQLHENV

I'm trying to connect my Ruby on Rails application to a legacy Database that is in a Microsoft SQL Server 2008. I have looked around different tutorials, pages, help pages, and question pages and still haven't been able to make it work. I'm using: Ubuntu karmic Rails 2.3.5 Ruby 1.8.7 activerecord-odbc-adapter 2.0 activerecord-sqlserve...

How to I serialize a large graph of .NET object into a SQL Server BLOB without creating a large buffer?

We have code like: ms = New IO.MemoryStream bin = New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bin.Serialize(ms, largeGraphOfObjects) dataToSaveToDatabase = ms.ToArray() // put dataToSaveToDatabase in a Sql server BLOB But the memory steam allocates a large buffer from the large memory heap that is giving us prob...

Why isn't Entity Framework recognizing my procedure?

I am trying a function import, and EF doesn't recognize my procedure. That's it: ALTER PROCEDURE dbo.AddNewTicketFieldOption ( @ticketFieldID INT, @optionID INT ) AS BEGIN INSERT INTO tbTicketFieldOptions (cdTicketField, cdOption) VALUES (@ticketFieldID, @optionID) --only to return something, EF hack SELECT 0 ...

How to Stream data from/to SQL Server BLOB fields?

For the background to this question, see “How to I serialize a large graph of .NET object into a SQL Server BLOB without creating a large buffer?” that now has a large bounty on it. I wish to be able to use a Stream object to read/write data to/from a BLOB field in a SQL Server row without having to put the all the data in...

How would I encrypt string data in SQL server 2008 while keeping the ability to query over it?

I have a database that will be hosted by a third party. I need to encrypt strings in certain columns, but I do not want to loose the ability to query over the encrypted columns. I have limited control over the SQL instance (I have control over the database I own, but not to any administrative functions.) I realize that I can use a .ne...

SQL Server version of MYSQL insert into

I have the following query running on a MySQL, but it fails when I run it on a SQL Server database. How should it look to please SQL Server? INSERT INTO first_table (pk, data) VALUES ((SELECT value FROM second_table WHERE key = 'key'), 'other-data'); ...

Query sql on string

hi all, I have a db with users that have all this record . I would like to do a query on a data like CN=aaa, OU=Domain,OU=User, OU=bbbbbb,OU=Department, OU=cccc, OU=AUTO, DC=dddddd, DC=com and I need to group all users by the same ou=department. How can I do the select with the substring to search a department?? My idea for the s...

Using Regex in SQL Server, I couldn't solve the following problem.

Hello all, I have strings like that OPEN SYSTEMS SUB GR (GM/BTIB(1111)/BTITDBL(2222)/BTVY(4444)/ACSVTYSAG) and I need to extract 2222 from it. What I was doing is this on the GROUPS String: SUBSTRING(GROUPS, CHARINDEX('(',GROUPS, CHARINDEX('(',GROUPS, CHARINDEX('(',GROUPS,0)+1)+1)+1, 4 ) AS GroupNo However I see that it is no...

MS Visio Category relationships to SQL Server

I'm using MS Visio to model a database and part of the model contains Transaction categories - the parent table has a transactionId, timestamp, amount, and transactionType. There are three child tables - cheque, bank transfer, and credit card, all related to the parent by transactionId. Is there a specific way this kind of relationship...

SQL Server Windows Authentication using a Service

I am running a Java Application as a Service in Windows that's using JDBC to connect to SQL Server. This application is started as a different user than the one logged into the Machine. My question is will the JDBC Driver use the user assigned to start the service to authenticate against or the logged in user (which there might not be on...

What is the standard way to constantly check SQL Server connection?

In a WPF application I use LINQ to SQL queries inside try - catch constructions to process exceptions, in case there is something wrong with DB server connection. The problem is - I have some queries executing on a timer-polling basis. So, if connection fails, I have numerous long queries attempts and UI is freezing. What is the stand...

Selectively restoring a database

I have been using this query: BACKUP DATABASE RentalEase TO DISK = 'C:\RentalEaseBackup\RentalEase.bak' WITH COPY_ONLY; GO To backup my database. Someone deleted something so now I have to restore it from a previous point in time, however I don't want to overwrite new changes (other than the deletions). What I was thinking I could do...

How Does Dateadd Impact the Performance of a SQL Query?

Say for instance I'm joining on a number table to perform some operation between two dates in a subquery, like so: select n ,(select avg(col1) from table1 where timestamp between dateadd(minute, 15*n, @ArbitraryDate) and dateadd(minute, 15*(n+1), @ArbitraryDate)) from numbers whe...

Tools for Building an OCA (Occasionally Connected Application)

I will be building an in-house, Occasionally Connected App (OCA). What technologies would you suggest I employ. Here are my parameters: .NET Shop(3.5sp1) C# for code behind (winform,wpf,silverlight) SQL Server Backend (2005 or possibly 2008 pending approval) Solo Developer Solo SQL Administrator Low Tech end users Low bandwidth to 5 B...

Measure transaction log throughput?

After reading Kim Tripp's article on transaction log throughput and discovering that I have gazillions of VLFs, I'm planning to restructure the logs as she outlined. I want to measure the resulting increase in log throughput to see if the fragmentation makes a difference on my servers, but I'm at a loss as to how to do so. I couldn't fin...

Spring Jdbc query execution

Does anyone know how what Spring Jdbc template method I could use to execute this 'upsert' or an alternative approach that would also perform the operations in one database call? UPDATE jasper_report SET Uri = 'update' WHERE ReportId = 99; IF @@ROWCOUNT = 0 AND Exists(Select 1 FROM report Where Id = 99) BEGIN INSERT INTO jasper_r...

Change the location of the Auto Recovery information in SQL Server Management Studio.

Our local IT has our My Documents folder on a network path. This causes a problem from MSQL Server management studio as it saves it auto recovery information every 10 min it will lock up as its doing its save. I found where VS2008 saved its setting but I can not find out how to change it out of My Documents for this. Does anyone know w...