sql-server

Transaction not rolling back

I have a transation that doesn't seem to rollback and getting a strange error. I'm using a transaction that is connected to SQL Server 2008 on a different server and MSMQ on the same server as the code. Here is an example of the code: void MyMethod() { try { using (var outterTrans = new TransactionScope())...

Why is 1899-12-30 the zero date in Access / SQL Server instead of 12/31?

More out of curiosity than any real problem; the question came up today and I know I've seen 1899-12-30 used as a "default" date and a zero date in Access and older SQL Server apps. Just wondered why - where did that come from, and why isn't 1899-12-31 used then? ...

SQL Server 2008r2 <--> best version of MS Access for front end

I am upsizing my back-end from Access 2003 to SQL Server 2008 R2. My pilot migration attempt went all right, but it appears the Access 2003 front-end won't play well. (I can make native links if I convert it to an .adp project, but then I can't modify the front-end; so it's back to .mdb, which uses (slow) ODBC links.) Apparently I s...

Does SQL Server have a feature similar to Oracle Streams Advanced Queuing?

Oracle Streams AQ (Advanced Queuing) provides highly scalable database-backed queuing functionality. Does an equivalent feature exist in SQL Server (any version)? Note: I do not mean simply using a table as a queue, but a specific vendor-provided enhancement to the database platform. ...

What data type does the SQLCommand method ExecuteScalar() return?

In SQL Server, ID is a not null integer, and an identity. When I run the following code, I get an InvalidCastException on the last line: SqlCommand cmd = new SqlCommand(); cmd.Connection = _conn; cmd.CommandText = @"INSERT INTO [Users] (Name, Email, Password) VALUES (@name, @email, @pass); SELECT SCOPE_IDENTITY()"; cmd.Parameters.Add...

PHP Apache SQL Server production environment on OS X

I have a client who wants me to build a site using PHP and SQL Server. Problem is I do all my PHP development in OS X running Apache. I have one machine running Windows with an SQL Server production environment but I can't seem to connect via "sqlsrv_connect" because I can't install the drivers for sql server on my Mac Has anyone found ...

Sql server Code Reuse

I have a table with about 30 fields. I current have several stored procedures which access either a (aggregated) view of this table or the table itself. For many of these SPs I would like to assure that the returned records have all the same fields with the same column names. Is there a way to do this where I don't have to change 20 ...

SQL, parse string like "12M" to 12 * 30 as an int

Hi, In a stored procedure in SQL Server 2008, I need to parse strings like "12M" and return 12 * 30 days as an int. So, I am basically parsing and calculating the number of days the string represents. I am not sure how this can be done. I am thinking to do a while loop over each character in the string. Any suggestion? Edit (not aut...

SqlDependency & OnChangeEventHandler discovering what data has changed?

When using SqlDependency & OnChangeEventHandler in .Net with SQL Server, is it possible (simple?) to discover what data has changed? ...

SQL 2008 Fulltext Index with Autocomplete

I've implemented a simple suggestive keyword autocomplete plugin that reads off the sys.dm_ftw_index_keywords table as follows: SELECT top 5 words.display_term, SUM(words.document_count) as c FROM sys.dm_fts_index_keywords (db_id(), object_id('testtable')) words WHERE (display_term LIKE '%test%' AND keyword != 0xFF) GROUP BY words.displ...

Read value of XML attribute in SQL Server 2005

Hello, I have one table contains field named source with varchar(max). That field has following value <OutPatientMedication DateFormat="MM-dd-yyyy" MedicationName="lisinopril 10 mg oral tablet" Instructions="2 cap(s) orally once a day " Status="Active" Quantity="0" Refills="0" Prescrip...

Copy schema and data changes from one SQL Server DB to another

Hello Experts, Can someone please advise me on the below. I have 2 databases, both of then were identical until few years back when we started to add more tables, procedures, views triggers etc to one of the database. Now i have to copy all the changes made in database 1 to database 2. Please, can someone throw some pointers or links...

Database search engine - Sort by relevance according to specific relevance rules

Hey, From my employer I just got a list of requirements for a new search function for our websites. They're book publisher's websites, so that's the basic field we're operating in here. The data is stored in a Microsoft SQL 2005 database server (SP3) with fulltext enabled. Now, the requirements state that the search can be done in thre...

SQL Server (SQLEXPRESS) and SQL Server Agent (SQLEXPRESS)

Hello there, I came across these two services separately running in Services.msc - SQL Server (SQLEXPRESS) - started+Automatic SQL Server Agent (SQLEXPRESS) - Disabled Can you please guide why do we need SQL Server Agent (SQLEXPRESS)? Thank you! ...

InstanceOwnerException when running Workflow Foundation 4

I am running Workflow 4 activities, and using SQL Durable Instancing to persist the Workflow when it's suspended. I am intermittently getting an InstanceOwnerException, which is remedied by recreating the instance store. Is there any way of avoiding this exception in the first place? System.OperationCanceledException: An error processin...

how to create trigger in MS SQL 2005

I need to update the record status(field name IsActivate-this holds the status of record) but needs to check first if the data is used in another table(meaning table is having a relationship with another table).If the data that I want to update is used in another table, update is not allowed else it should be updated.How can I can create...

SP: handling nulls

Hi! I have this Table structure: Id int not null --PK Title varchar(50) ParentId int null --FK to same Table.Id I'm writing a SP that returns a row's "brothers", here's the code select * from Table where Table.ParentId = (select Table.ParentId from Table where Table.id = @Id) and Table.Id <> @Id It works perfectly for rows having ...

SQL Server: how to constrain a table to contain a single row ?

I want to store a single row in a configuration table for my application. I would like to enforce that this table can contain only one row. What is the simplest way to enforce the single row constraint ? ...

Distributed Database Communication

Hello, I am a junior software engineer,I like this site and people in it.So,I want to ask my problems to see your answers and suggestions.Then,please don't mad at me for asking without searching. My problem is about Distributed database communication(MSSQL Server 2008).In picture,I need a Main Server in center of star topology and othe...

Root cause of an "Invalid object name: dbo.etc" error?

I'm doing some maintenance programming on a fairly large project, which was started by someone who's now left the company... I've just backed up one of the company's databases, and then reattached it to our test server. That much appears to be working okay. I then go through the program's usual login procedure, and that part also appea...