sql-server

How does the DataContext handle concurrency?

I wonder how the DataContext handles concurrency violation. For example - Two users are fetching some data from the database, then some of them change some row and commit changes, then other user trying commit their changes so a ChangeConflictException should occur, but how does the DataContext know that the data has changed? Fetch...

Selecting a group of names

I am struggling with a query in SQL Server 2005-2008 There are 15 participants in a tournament. Every day, 7 random participants are chosen. Out of the 7, one is the teamleader. The condition is that if a person has become a teamleader once, he cannot become again till all the others (rest 14) have got their chances. How can i write ...

How can I programmatically check (parse) the validity of a TSQL statement?

I'm trying to make my integration tests more idempotent. One idea was to execute rollback after every test, the other idea was to some how programatically parse the text, similar to the green check box in Query Analyzer or SSMS. How do I get SQL Server to parse my command without running it using ADO.NET? UPDATE: This is what finally...

How to access Postgres data from SQL Server (linked servers)

I have the following situation: DB Server 1 is Sql Server 2008 and hosts database A with transaction records DB Server 2 is Postgres and hosts database B with records of prices Server2 is added as a linked server to server1. I need to run a query where for each transaction record on server1 I need to check a number of prices from serv...

TSQL Howto get count of unique users ?

This is really dumb question but still my head cannot work it out. I have a table with Orders, each order has userID in it. User can have unlimited amount of Orders. How do i make count of unique userIDs ? ...

SSAS data mining web viewer

Hi, I need to allow my end users to view SQL Server Analysis Services data mining model (to be exact Association finding). I'm looking for a tool which can do the job. For the cubes I'm using Excel OWC, and I'm quite satisfied. So far I had found only DM Companion . But I'm struggling to find anything else. Can you recommend somethi...

Is the SRV_PROC Structure Compatible With Oracle's Extended Stored Procedure?

In a SQL Server external stored procedure(written in C) that I am trying to migrate, the SRV_PROC structure is the entrance parameter for a used method. Is it possible to call this method in Oracle or do I have to change the data type into something else? Is there any workaround for this situation? ...

Memcached vs SQL Server cache

I've been reading a lot of articles that suggest putting a Memcached (or Velocity, etc) in front of a database is more efficient than hitting the database directly. It will reduce the number of hits on the database by looking up the data in a memory cache, which is faster than hitting the database. However, SQL Server has it's own memo...

Why would moving our .NET /SQL Server website to a new host cause connection pool size to be exceeded?

We've recently moved our company website to a new host. It is an ASP.NET site with C# code behind, connecting to MS SQL server. Since moving the site to the new server, the site is exceeding the connection pool limit (which is not set explicitly, so I believe is at the default size of 100). Inspection of the open processes via SQL Serv...

Title: UPDATE is not allowed because the statement updates view "table_name" which participates in a join and has an INSTEAD OF UPDATE trigger.:

i am getting the following error while executing the following query in an Stored Procedure..Could anyone help in finding the fault? UPDATE is not allowed because the statement updates view "sup_item" which participates in a join and has an INSTEAD OF UPDATE trigger. UPDATE si SET name = mc.name, sup_item_cat_id = mc.res_sup_i...

Is it possible to convert nvarchar to int?

Hello all, I have tried something like this: select PREPRO = case when (isnumeric(PREPRO) = 1 and PREPRO in ('0','1','-1')) or convert(varchar, PREPRO) in ('True','False') then convert(bit, convert(integer, PREPRO)) else 'No' end from dbo.TI10SE The PREPRO contains all "False". I get this error: Conversion failed when converting ...

Passing SQL stored procedure entirety of WHERE clause

I have a SQL stored procedure of the form SELECT [fields] FROM [table] WHERE @whereSql I want to pass the procedure an argument (@whereSql) which specifies the entire WHERE clause, but the following error is returned: An expression of non-boolean type specified in a context where a condition is expected Can this be done? ...

What data type do I choose for storing plain text in Microsoft SQL Server 2008?

For example, there is a string field Name in my C# (Linq-to-SQL); what data type would that SQL field have to be? varchar? nchar? I'm confused. ...

Attach Databse Using SMO keep Failing....

i use this SMO code to attach a database. Server mServer = new Server("."); mServer.AttachDatabase("DbName", new StringCollection { "DbName.mdf", "DbName_log.LDF" }, AttachOptions.None); But i keep getting the exception Failed to connect to server. Any Ideas? [EDITED] Inner Exception...

SQL Stored Procedure Question

Hello All! I'm having an issue trying to set variable in SQL in a stored procedure. I'm checking to see if a record is set to active, and the idea is to set it to inactive or vice versa. Admittedly I'm not the best with SQL and have tried CASE statements along with my example, but nothings working... Could someone show me what I'm mis...

Can you review my simple SQL database and perhaps provide some feedback on things I may have overlooked? (7 Tables)

Here is the SQL script: create table Employee( Carnet nvarchar(15) primary key, Name nvarchar(500), LastName nvarchar(500) ) create table Document( ID nvarchar(20) primary key, Employee nvarchar(15) foreign key references Employee(Carnet), Project nvarchar(20) foreign key references Project(ID) ) create table DocumentsArea( DocumentID...

How do I Get a WCF Service & a Website calling it to execute under your network login rather than NETWORK Service

When I developed a site with VS 2008 it happily connected to a the webservice in the solution, then connected to the database (using ADO.Net Entities) and ran my query. Now I come to rolling out the site. When it connects to the webservice it is connecting as NETWORK SERVICE - which I don't want - I need it to connect as 'MYCREDENTIAS'....

Subsonic updates multiple rows instead of 1 ????

Subsonic 3.0 is updating multiple rows instead of just the one it's supposed to DB Table is defined as follows - Col1 int NOT NULL Col2 Text NOT NULL Col3 INT NOT NULL ColX NTEXT COLY NTEXT Primary Key = Col1 + Col2 + Col3 .... the select expr is as follows myTable a = myTable.SingleOrDefault( x => x.Col1 = 1 && x.Col2 = 'a...

How do I declare a field to be an identity in Microsoft SQL Server?

For example, the column ID. I want it to start at 1, and then increment by 1 for each row. Thank you! ...

How to enable utility control point in SQL Server 'Standard Edition (64-bit)'?

I was trying to register a 64 bit machine under new Utility control point name, get the following "The SQL Server edition must support UCP creation. Validation failed. The specified instance of SQL Server cannot be used as a utility control point because the feature is not enabled in SQL Server 'Standard Edition (64-bit)'. For more info...