sql-server

SQL Server STATISTICS

So for this one project, we have a bunch of queries that are executed on a regular basis (every minute or so. I used the "Analyze Query in Database Engine " to check on them. They are pretty simple: select * from tablex where processed='0' There is an index on processed, and each query should return <1000 rows on a table with 1MM reco...

Is it possible to enable compression with SQL Server 2005 Replication

I am sending data across a link with very little bandwidth and I will probably be sending large data files. I have Merge Replication and Snapshot replication configured at present. Is it possible to enable compression in SQL Server 2005 replication and if so, how? Thanks. ...

How can I add SQL Server database objects to TFS?

We don't currently have our SQL Server objects in any form of source control. We recently installed TFS 2008 and I'd like to get our SQL server code added. I think I could script all of the database and create script files for each object, but I'm hoping there is a way to point to a database in SSMS and create a project that can be added...

Row Offset in MS SQL Server

Is there any way in MS SQL Server to get the results starting at a given offset? For example, in another SQL server, it's possible to do: SELECT * FROM MyTable OFFSET 50 LIMIT 25 to get results 50-74. This construct does not appear to exist in MS SQL. How can I accomplish this without loading all the rows I don't care about? Thank...

MS SQL datetime prior than 1/1/1900

Surely there is a way to store a date value prior than 1-1-1900 in a column other than varchar? Or do I really have to break this out, and perform my own datetime library for date differences, sorting, and such? Yes, I understand how datetime's are actually stored (an integer value from a specific date), but I remember there being anoth...

Data Types supported in visual studio 2008

I just downloaded and installed the latest Adventure Works database from http://www.codeplex.com/MSFTDBProdSamples/Release/ProjectReleases.aspx?ReleaseId=16040 to do some more playing around with LINQ and found that there are some data types that are not natively supported within Visual Studio 2008. I get the "One or more selected items ...

Analysis Service - Proactive caching failing

For a while the proactive caching process successfully sync the OLAP databse and then is starts giving the following error 'Errors in the OLAP storage engine: The attribute key cannot be found:' followed by spesific data related information. I do not however have a problem if I manually process the databse with the 'Transactional Deploye...

How to import data from Excel 2007 xlsx file into SQL Server 2000 Database?

SQL Server 2000 doesn't seem to support the xml based .xlsx file types. Besides converting the file to a 97-2003 file type, how else can I achieve this? ...

How do I determine if a column is an identity column in MSSQL 2000?

I want to do this in code, not with ALT+F1. ...

SQL Server 2000 constraint involving column on different table

I would like a constraint on a SQL Server 2000 table column that is sort of a combination of a foreign key and a check constraint. The value of my column must exist in the other table, but I am only concerned with values in the other table where one of its columns equal a specified value. The simplified tables are: import_table: part...

How do I create and query linked database servers in SQL Server?

I need to do a join across two different database servers (IPs 10.0.0.50 and 10.0.0.51). What's the best way? ...

How to keep row order with SqlBulkCopy?

I'm exporting data programatically from Excel to SQL Server 2005 using SqlBulkCopy. It works great, the only problem I have is that it doesn't preserve the row sequence i have in Excel file. I don't have a column to order by, I just want the records to be inserted in the same order they appear in the Excel Spreadsheet. I can't modify th...

7645 Null or empty full-text predicate

I have a query that ran fine on SQL2005 but moving the database to SQL2008 gives me the error from the title. The code that is the problem is a call to CONTAINS, CONTAINSTABLE or FREETEXT with an empty parameter. However I'm trying to only call or join when there is a value like such where (@search_term = '' or (FREETEXT(lst.search_tex...

Should we upgrade to SQL Server 2005 or 2008?

Our company is considering upgrading our SQL server. At this point, would it be better to upgrade to 2005 or 2008? Here are some of my considerations: Features Licensing costs Learning curve Bear in mind our staff has already been using SQL server 2000 for many years. ...

Weird SQL Server memory errors after upgrading to 64-bit

We've just "upgraded" our production database server from 32-bit to 64-bit. It's running SQL Server 2005 Standard on Windows Server 2003. During the night after the upgrade the server was unavailable for nearly an hour - client requests were timing out. The problem then seemed to fix itself. The only clue I have as to the problem is what...

How do you effectively model inheritance in a database?

What are the best practices for modeling inheritance in databases? What are the trade-offs (e.g. queriability)? (I'm most interested in SQL Server and .NET, but I also want to understand how other platforms address this issue.) ...

SQL Server - separate database for reports?

On our SQL Server, we have a database for each of our web apps. For reports, we use Reporting Services and all report data (including report parameters) come from stored procedures. The stored procedures are in the same database as the data in the report. So, for example, the procs that serve the Stock reports are in the Stock database...

Initialise A Variable With The Output Of A Stored Procedure In MS SQL Server

I have created the following stored procedure.. CREATE PROCEDURE [dbo].[UDSPRBHPRIMBUSTYPESTARTUP] ( @CODE CHAR(5) , @DESC VARCHAR(255) OUTPUT ) AS DECLARE @SERVERNAME nvarchar(30) DECLARE @DBASE nvarchar(30) DECLARE @SQL nvarchar(2000) SET @SERVERNAME = Convert(nvarchar, (SELECT spData FROM dbSpecificData WHERE spLookup = 'CM...

Has anyone used (or considered using) Sql Server Compact Edition?

Hi, I've been preparing to deliver a presentation on SQL Server Compact Edition 3.5 (SP1 - recently released) and I was wondering if anyone had designed (or contemplated designing) a system with SQL Server CE 3.5 (or earlier versions)? In particular, has anyone thought of (or experienced) using SQLCE as a solution for offline data stora...

How do you convert VARCHAR to TIMESTAMP in MSSQL?

You'd like to call a stored proc on MS SQL that has a parameter type of TIMESTAMP within T-SQL, not ADO.NET using a VARCHAR value (e.g. '0x0000000002C490C8'). What do you do? UPDATE: This is where you have a "Timestamp" value coming at you but exists only as VARCHAR. (Think OUTPUT variable on another stored proc, but it's fixed alread...