sql-server-2008

What's the most efficient way of querying the database based on a list of values?

I have a list of record Id's that I want to retrieve from Sql Server. I'm trying to figure out what the most performant way doing this would be. For example in code I have this: var recordsToFind = new List<long>{ 12345, 12346, 45756, 42423 ... } I want to create a stored proc that does this: Select * From Puzzles where ID = {any of ...

SQL Server 2008 First Day Criteria Are Met

Hello. I have a data table (will be millions of records but I will make it simple here) that looks like this. ID APPROVAL_DT DAY_DT TRANS_COUNT SALE_AMOUNT 1 2010-04-22 2010-04-27 2 260 1 2010-04-22 2010-04-28 1 40 2 2010-03-28 2010-04-02 1 ...

How can I send plain text email (with line breaks) using sp_send_dbmail?

I have a SQL Server 2008 procedure that sends email via sp_send_dbmail. I'm using the following code: set @bodyText = ( select N'Here is one line of text ' + N'It would be nice to have this on a 2nd line ' + N'Below is some data: ' + N' ' + ...

connect to remote sql server with different windows credentials

Is there a way to connect to a remote sql server using management studio with windows credentials other than the current login credentials? Right now i remote desktop into the sql server machine and login with the windows credentials that I want to connect with. Thanks. ...

SQL Server 2008: Parameters with T-SQL statements

I want to know if it is possible to show a parameter with some T-SQL statement. For example, there is a PARAMETERIZATION parameter. One can set it with such statement: SET PARAMETERIZATION FORCED How to know parameter's status? ...

SQL Server 2008 installation issues

I had installed SQL Server 2008 and received a error now after about 7 months that the evaluation period has expired; without any previous notifications. I searched online and found that I needed to make a change in the registry and reinstall SQL Server 2008. I am trying to do upgrade install and getting the error: Rule "SQL Server A...

"This server version is not supported.Only Up To Microsoft SQL server 2005 are supported" in Visual Studio 2008 Cannot Connect to SQL server 2008 R2

Getting this error "This server version is not supported.Only Up To Microsoft SQL server 2005 are supported" after I create a data connection in Visual Studio 2008 SP1 and SQL server 2008 R2. Any ideas would be great. No other version of SQL server Installed. The error occurs after I select server, then database. Just as I click OK I ...

TSQL to tell which network protocol is being used for each active session

Once upon a time, I remember running some TSQL which would display which network protocol (e.g. named pipes, TCP/IP) was being used by each active session - but I can't remember the actual code. Does anyone know how to do this ? An input parameter might have been SPID. The code was useful for diagnostic purposes. ...

systable for sql server

Is there any system table to find the columns for DDLChangeLog_ID, InsertionDate,CurrentUser, LoginName, Username, EventType, objectName, objectType, tsql ...

SQL 2008 Express (R2): Creating an UPDATE trigger to update a table on another server?

Hi there, I am just trying to think through a process I need where I have: One SQL 2008 express database on a webserver - takes orders into an orders table Another SQL 2008 express database on another webserver acting as a backend system to process the orders etc The idea being that the webserver database can be left to do what it d...

Query compatibility SQL server 2008/2000

Hi, I am developing some stored procedures in SQL Server 2008. Some of our customers are running SQL Server 2000. Is there a way to check whether my queries are compatible without having to install SQL Server 2000? Maybe a transact sql tester? Regards, Michel ...

SysIndex - difference b/w is_unique and is_unique_constraint

runing a select query on SQL Server 2008, sys.indexes gives me information on the index define for a database . There 2 fields is_unique and is_unique_constraint. I dont understand the difference b/w them . ...

how to assign NULL value in sql server 2008?

Cusid Cusgroupid Productid 5 NULL NULL ppid cusgroupid list bulk cost billing 854 NULL 45.00 42.00 42.00 42.00 855 2 39.00 36.00 33.00 30.00 I want to compare two table, expect result is 1, if cusgroupid is 2 only select that row ppid cusgroupid ...

Scripting setup of database mail

I've used the SQL Server 2008 GUI to set up database mail profiles & accounts on my test server, and I'd now like to duplicate those to our production database. Is there a way to generate a script to do this? ...

Create a script in MMSE Express - question about certain part of script.

When I create a script with the Management Studio, it includes this part: WITH ( PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 70 ) What are those options and are they required? Thanks :) ...

32bit ODBC and 64bit SQL Server

I have a 64bit server running Windows Server 2008 and MSSQL 2008, both in 64bit. I also have an application which queries a second system but can only work in windows server 2003 32bit. I want to connect both systems via a service that would run on the 32bit system and connecting to MSSQL via ODBC. What are the pitfalls? Has anyone trie...

SQL Count across 3 tables

I have a query that works fine when there is data but not when I have nothing in the charities table. Any help would be hugely appreciated. SELECT C.CategoryId , C.CategoryName , ISNULL(COUNT(CC.CharityId), 0) as CharityCount , C.IsDeleted FROM Charity.Categories C LEFT JOIN Charity.CharityCategories CC on C.CategoryId =...

Update statement running for too long or not

I'm new to working with this much data (20 million rows) and I don't know what I should expect as far as query duration: update table set field = '1234' No index on field. This statement took 25 minutes. The database is set to Simple Recovery. Does 25 minutes seem too long? Table has 9 columns with small data types <50 varchar. ...

SQL Server 2008 evaluation edition

My evaluation edition expired and I do not have a licensed version. Can I uninstall and then reinstall another evaluation edition and if not will I be able to restore my databases to a SQL Server 2008 Express edition? ...

Building an incremental query using SQL Server and .NET

I am working on an ASP.NET MVC project which allows users to construct arbitrarily complex queries by adding items clause at a time. The application then generates appropriate SQL, runs it (currently using SQL Server 2008) and displays the results, with a breakdown which includes the number of matching records for each added item. e.g....