sql-server

Simple check for SELECT query empty result

Hi. Can anyone point out how to check if a select query returns non empty result set? For example I have next query: SELECT * FROM service s WHERE s.service_id = ?; Should I do something like next: ISNULL(SELECT * FROM service s WHERE s.service_id = ?) to test if result set is not empty? ...

Currency Exchange SQL Server Database

I need historic and daily currency exchange rates database to work with BI solution based on Microsoft SQL Server. Thanks for the help. ...

How to test if a SQL Server 2008 database can serve 200 concurent users

I have a SQL Server 2008 database in 3NF. I must check if the db can support many concurent users. Which is the best method ? Is there any free tool to do this ? Thank you very much. ...

Stored Procedure generator tool

I am looking for tool which will generate the basic stored procedure structure (CRUD operations) for the given table, Is there any tool for the same? ...

How can I optimize retrieving lowest edit distance from a large table in SQL?

Hey, I'm having troubles optimizing this Levenshtein Distance calculation I'm doing. I need to do the following: Get the record with the minimum distance for the source string as well as a trimmed version of the source string Pick the record with the minimum distance If the min distances are equal (original vs trimmed), choose the trim...

SQL Server: Find Values that don't exist in a table

I have a list or set of values that I would like to know which ones do not currently exist in a table. I know I can find out which ones do exist with: SELECT * FROM Table WHERE column1 IN (x,x,x,x,x) The set is the values I am checking against. Is there a way to find out which values in that set do not exist in column1? Basically, I'm...

Cannot open database "DataDir" requested by the login. The login failed

Hi, I have a single user software that uses SQL Server database 2005. My computer was crushed while my software was on. I saved a copy of my database after I rescued my computer. However my software gives my following message. ( I don't know anything about SQL) However, I guess my database has the last login information. Since software w...

SQL Server 2008. Allow Remote Connections?

I have SQL Server 2000 and 2008 installed on a Windows XP Pro box. I can connect to both db instances locally. From another box, a Windows 7 box, I can connect to the SQL 2000 instance on the first box but I cannot connect to the 2008 instance using the same SQL Server authentication credentials that worked locally. Allow Remote Connec...

How do you escape double quotes inside a SQL fulltext 'contains' function?

How do you escape a double quote character inside a MS SQL 'contains' function? SELECT decision FROM table WHERE CONTAINS(decision, '34" AND wide') Normally contains() expects double quotes to surround an exact phrase to match, but I want to search for an actual double quote character. I've tried escaping it with \, `, and even anoth...

Can a Snapshot transaction fail and only partially commit in a TransactionScope?

Greetings I stumbled onto a problem today that seems sort of impossible to me, but its happening...I'm calling some database code in c# that looks something like this: using(var tran = MyDataLayer.Transaction()) { MyDataLayer.ExecSproc(new SprocTheFirst(arg1, arg2)); MyDataLayer.CallSomethingThatEventuallyDoesLinqToSql(arg1, argEtc);...

SQL Server Query Slow from PHP, but FAST from SQL Mgt Studio - WHY???

I have a fast running query (sub 1 sec) when I execute the query in SQL Server Mgt Studio, but when I run the exact same query in PHP (on the same db instace) using FreeTDS v8, mssql_query(), it takes much longer (70+ seconds). The tables I'm hitting have an index on a date field that I'm using in the Where clause. Could it be that PHP...

Need SQL Server Stored Procedure for This Query

I have a ASPX.NET DataGrid and im trying to USE a select LIKE 'X'% from a table that has 1 field called location. im trying to display the locations that start with a certain letter (example wxxx,axxx,fxxx,) in different columns in my data grid. I am trying to display more than 1 column in my datagrid using a SP shown below. The issue i...

SQL Server indexed view matching of views with joins not working

Does anyone have experience of when SQL Servr 2008 R2 is able to automatically match indexed view (also known as materialized views) that contain joins to a query? for example the view select dbo.Orders.Date, dbo.OrderDetails.ProductID from dbo.OrderDetails join dbo.Orders on dbo.OrderDetails.OrderID = dbo.Orders.ID cannot be automat...

my output parameters are always null when i use BeginExecuteNonQuery

I have a stored procedure that returns a varchar(160) as an output parameter of a stored procedure. Everything works fine when i use ExecuteNonQuery, i always get back the expected value. However, once i switch to use BeginExecuteNonQuery, i get a null value for the output. I am using connString + "Asynchronous Processing=true;" in bo...

Webservice for Watching a Table in SQL server and populating it.

Can we write a web service to watch a table in sql server. whenever the corresponding table is populated with new records, the new records should appended to the another table which has the same structure of the old one. Is this is possible using webservices if not how to perform this. ...

Fastest way to move records from an Oracle database into SQL Server

Ok this is the scenario... I have a table in Oracle that acts like a queue... A VB.net program reads the queue and calls a stored proc in SQL Server that processes and then inserts the message into another SQL Server table and then deletes the record from the oracle table. We use a DataReader to read the records from Oracle and then ca...

Caching stored procedure results in Linq'u

In our web application we have a lots of stored procedures look like this one: getSomeData(/* 7 diffrent params */) This stored procedure don't make any updates. We are using Linq'u. I know that the date are changing no often than once per day so the results for the same sets of parameters values will be the same. Does Linqu have ...

Best practices to delete a set of tables in sql 2008

Basically I want to keep the transaction very simple but I should be able to rollback if any error occurs in the later part. Something like: BEGIN TRANSACTION DELETE SET 1(this will delete first set of table) COMMIT DELETE SET 2 (will delete second set of table) If any error occurs while deleting set 2 I should be able to roll...

Can't see *all* databases in a remote SQL Server instance

I can connect to a remote SQL 2008 Server instance, but I cannot see all the databases in the instance using SQL Server 2008 Management Studio. I suspect that my problem has something to do with not all database in the remote instance having the same version. For example, I "upgraded" a 2005 database to 2008 by doing a backup from 2005 ...

Wildcards in T-SQL LIKE vs. ASP.net parameters

In my SQL statement I use wildcards. But when I try to select something, it never select something. While when I execute the query in Microsoft SQL Server Management Studio, it works fine. What am I doing wrong? Click handler protected void btnTitelAuteur_Click(object sender, EventArgs e) { cvalTitelAuteur.Enabled = true; cvalT...