sql-server

SqlServer 2000 compatibility

The developer environment db server is SqlServer 2005 (developer edition) Is there any way to make sure my SQL Queries will run in SqlServer 2000? This database is set to Compatibility level "SQL Server 2000 (80)" but some queries that run without problems in the development system can not run in the Test Server (SqlServer). (The prob...

PHP/MSSQL Report Writing

What is a good method of writing reports using PHP and MSSQL? Is there a third party vendor that supports MSSQL? ...

Is it possible in SQL Server to create a function which could handle a sequence?

We are looking at various options in porting our persistence layer from Oracle to another database and one that we are looking at is MS SQL. However we use Oracle sequences throughout the code and because of this it seems moving will be a headache. I understand about @identity but that would be a massive overhaul of the persistence code....

XQuery to get list of attributes

If I have several Section elements in an XML document, what XQuery do I use to get a list of all the name values? <Section name="New Clients" filePath="XNEWCUST.TXT" skipSection="False"> ...

JDBC & MSSQL seem to be truncating large fields

I'm using jython 2.2.1, and jdbc 1.2 and connecting to a mssql 2000 database, writing the contents of an email to it. When I get to the body of the email which can be quite large sometimes I need to truncate the data at 5000 chars. Except mssql & jdbc gang up on me like school yard bullies, when i check the database loads of my data is m...

Testing TRY...CATCH in SQL Server Management Studio

Solution: I've misinterpreted the example from SQL Books Online. Yes, that below the section Errors Unaffected by a TRY…CATCH Construct ... I'm so sorry :( I was just trying to execute this simple example in SQL Server Management Studio: USE AdventureWorks; GO BEGIN TRY -- Table does not exist; object name resolution --...

Multi-bit database field

I'm using a MSSQL database and would like to create a column that only has 4 possible values. Is there any way to define a 2-bit column? I see the bit datatype and then the next smallest is tinyint which is 1 full byte. If there is no such field, I'd be interesting in finding out why not. Thanks. ...

Backup Database from ServerGrid.com

Hello I have a hosting account with servergrid.com. I want to backup my database, they say I have to use Sql Server Integration Service to backup the database and I would need a commercial version of Sql Server management studio. I have Sql Server 2005 Developer Edition. I have no idea how to do SSIS backup. I tried playing around with...

Occasional Deadlock.

I'm having trouble with a web application that will deadlock occasionally There are 3 queries involved. 2 are trying to update a table UPDATE AttendanceRoll SET ErrorFlag = 0 WHERE ContractID = @ContractID AND DATEPART(month,AttendanceDate) = DATEPART(month,@Month_Beginning) AND DATEPART(year,AttendanceDate) = DATEPART(year,@Month_Begi...

How much overhead does 'Update Check' have for LINQ UPDATES

I have a simple row that I edit using LINQ. It has about 30 columns, including a primary key numeric sequence. When an UPDATE is performed through LINQ, the UPDATE statement includes all the columns of the table (for concurrency checking). I'm wondering how inefficient this is - if not negligibiel. Since there is an index on the prima...

SQL Server Database File and WCF

I have a WCF Service that exposes a method GetCustomers(). The internals of the method uses a Data Layer along with a Business Layer to return a List of Customers. Currently I am using an SQL Server Database file saved on the server. Everything works fine on my local network but I want to move this to the web. I thought the best method ...

How to restrict NULL as parameter to stored procedure SQL Server?

Hi, Is it possible to create a stored procedure as CREATE PROCEDURE Dummy @ID INT NOT NULL AS BEGIN END Why is it not possible to do something like this? ...

T-SQL: How to make cell-values unique?

If I have a table where the cells in a column should not have the same values, how do I check this and update? (I know I can set constraints in the settings, but I don't want to do that.) Say the column name is called unique hash name and contains Peter Peter Peter Dave Dave and so on. I want that to transform to: Peter Peter1 Pe...

What are the major benefits of SQL Server 2005/2008 compared to SQL Server 2000?

One of our clients is upgrading their servers because the old machines can't handle the load of the database anymore. They have been using sql 2000 for the last 6 years and the db has grown to hold a few GB of data. Will it be worth upgrading to 2005 or 2008? What are the major benefits of the new versions compared to 2000? ...

How to insert a record and return the newly created ID using a single SqlCommand?

I'm using an SqlCommand object to insert a record into a table with an autogenerated primary key. How can I write the command text so that I get the newly created ID when I use the ExecuteScalar() method? ...

SQL Relationships and indexes

I have an MS SQL server application where I have defined my relationships and primary keys. However do I need to further define indexes on relationship fields which are sometimes not used in joins and just as part of a where clause? I am working on the assumption that defining a relationship creates an index, which the sql engine can r...

Change default date time format on a single database in SQL Server

I need to change the date format from US (mm/dd/YYYY) to UK (dd/mm/YYYY) on a single database on a SQL server machine. How can this be done? I've seen statements that do this for the whole system, and ones that do it for the session, but I can't change the code now as it will have to go through QA again, so I need a quick fix to change...

Does SQL Server CheckSum calculate a CRC? If not how can I get MS SQL to calculate a CRC on an arbitrary varchar column?

Does SQL Server CheckSum calculate a CRC? If not how can I get SQL Server to calculate a CRC on an arbitrary varchar column? ...

How many columns are too many for a sql 2005 table?

I have a request to allow a dynamic table to have 1000 columns(randomly selected by my end users). This seems like a bad idea to me. It's a customizable table so it will have a mixture of varchar(200) and float columns(float best matches the applications c++ double type). This database is mostly an index for a legacy application and s...

SQL Server Certification - 2005 or 2008?

I'm interested in getting certified for SQL Server. Since you can either be certified for SQL Server 2005 or 2008, I'm not sure which one to pursue. It seems that there are more training materials for SQL Server 2005 certification and more companies use it. However, getting certified for SQL Server 2008 would mean that I'd be current ...