sql-server-2005

Identify full vs half yearly datasets in SQL

I have a table with two fields of interest for this particular exercise: a CHAR(3) ID and a DATETIME. The ID identifies the submitter of the data - several thousand rows. The DATETIME is not necessarily unique, either. (The primary keys are other fields of the table.) Data for this table is submitted every six months. In December, w...

Advantages of MS SQL Server 2008 over MS SQL Server 2005?

What are the key differences between MS SQL Server 2005 and 2008? Are there any compelling reasons for upgrading (any edition, as I have a customer with multiple editions)? Or can you point to a website with either a chart or bullet point comparison of the two servers? Also, is there anything noteworthy in the Express editions of ei...

PIVOT in sql 2005

I need to pivot one column (Numbers column). example need this data: a 1 a 2 b 3 b 4 c 5 d 6 d 7 d 8 d 9 e 10 e 11 e 12 e 13 e 14 Look like this a 1 2 b 3 4 c 5 d 6 7 8 9 e 10 11 12 13 14 any help would be greatly appreciated... ...

SQL Server command LIKE [0-9] won't match any digit between 0 and 9

This is the constraint I have on the Customers table. ALTER TABLE Customers ADD CONSTRAINT CN_CustomerPhone CHECK (Phone LIKE '([0-9][0-9][0-9]) [0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]') Why does this fail? INSERT INTO Customers (CustomerName, Address, City, State, Zip, Phone) VALUES ('Some Name','An Address', 'City goes here', ...

Job Status in SQL 2005

I have a Stored procedure which schedules a job. This Job takes a lot of time to get completed (approx 30 to 40 min). I need to get to know the status of this Job. Below details would help me 1) How to see the list of all jobs that have got scheduled for a future time and are yet to start 2) How to see the the list of jobs running and ...

How to undo a delete operation in SQL Server 2005?

Our Test DB is suddenly missing rows. We want them back. Is there a way to sift through everything that has happened to the database today? Each SQL statement? I presume this kind of stuff is in the transaction log, but am not sure how to view it. Is there a way to undo delete operations? BTW: Yes, we do have a backup, but would prefe...

How do I ensure Linq to Sql doesn't override or violate non-nullable DB default values?

I have an SQL Server DB with a table with these fields: A bit with the default value 1, NOT NULL. A smalldatetime with the default value gettime(), NOT NULL. An int with no default value, IDENTITY, NOT NULL. When I generate Linq to SQL for this table, the following happens: The bit is given no special treatment. The smalldatetime i...

SQL Server 2005 auto growth by size

I have been looking at the new database server we are setting up for a client and note the database files are set to grow by 1 meg everytime the file is full and the initial size is 100 MB. I have been considering this breifly and it doesn't sound right. I've checked a few sites on DB considerations and they didn't properly explain the...

Can a BCP version 8.0 format file have a column name that is a SQL keyword?

I have a format file where I want one of the columns to be "group". I'm auto-generating the format file and a client wants to upload a file with "group" as one of the columns. I could restrict it so they can't use SQL keywords, but then I need a function to determine if a column name is a SQL keyword, so I'd like to support the user be...

Hierarchical data in Linq - options and performance

I have some hierarchical data - each entry has an id and a (nullable) parent entry id. I want to retrieve all entries in the tree under a given entry. This is in a SQL Server 2005 database. I am querying it with LINQ to SQL in C# 3.5. LINQ to SQL does not support Common Table Expressions directly. My choices are to assemble the data in ...

Undo changes to SQL Server 2005 database

I've ran some "ALTER" scripts on the database [SQL Server Server 2005], and overwrote some sprocs. Is there any way to undo changes and get my old sprocs back? Is there a way to get the scripts that were executed out of the .LDf file? That way i can re-run my initial "create" script for my sprocs. I don't have a backup file with old sp...

TSQL Extended Procedure 'xp_dirscan'?

What is the equivalent of the extended procedure 'xp_dirscan' in SQL Server 2005? ...

What is the best datatype to use for storing moderate amounts of text in SQL Server (2005)?

What is the best datatype to use for storing moderate amounts of text in SQL Server (2005)? For example, imagine a table, storing information on downloads available on a website. I want a title for the download which is brief, say varchar(20). A path, say varchar(255) then I want to store some user friendly text about the download - a d...

Can an MS SQL 2005 backup be restored onto an instance of MS SQL 2008?

Is it possible to restore a backup of a SQL Server 2005 database onto an instance of SQL Server 2008? I need to rebuild a server as it's getting rather crufty, so I plan to take this opportunity to upgrade to SQL 2008 and wondered if I'll be able to restore my backups OK. ...

In SQL Server 2005, how do I set a column of integers to ensure values are greater than 0?

This is probably a simple answer but I can't find it. I have a table with a column of integers and I want to ensure that when a row is inserted that the value in this column is greater than zero. I could do this on the code side but thought it would be best to enforce it on the table. Thanks! I was in error with my last comment all i...

Sql Server Job steps

I am dynamically adding steps to a Sql Server Agent Job, but I need to get the last step id to determine the next id in the sequence. I cannot seem to find any built in sps that can give me this information. ...

Integrated Security for multiple domains?

Is there a way to connect to a db with Integrated Security from multiple domains? ...

How do I use full text search accross multiple tables, SQL Server 2005

I have a full text catalog with two tables in it. tableA has 4 columns (a1, a2, a3, a4) of wich 3 are indexed in the catalog, a2,a3,a4. a1 is the primary key. tableB has 3 columns (b1, b2, b3, b4), two of which are indexed in the catalog, b3 and b4. b1 is the PK of this table, b2 is the FK to tableA. I want to do something like SELE...

Move/copy SQL Server 2005 full text index

We are moving our database server to a bigger box. I have several databases with full text indexes. What is the best way to move the full text indexes? ...

How to call a SQL script from within another SQL script?

i want to call a series of .sql scripts to create the initial database structure script1.sql script2.sql etc. is there any way of doing this without sqlcmd or stored procedures or any other kind of code that is not sql ? just inside a .sql file. ...