sql-server

Storing Outlook emails in a Microsoft SQL Server database

I am using c# to write an Outlook 2007 add-in to store emails in a SQL Server 2005 database. I would like to be able to store the entire .msg file in a varbinary(MAX) field. Is there a way to do this without having to use the Outlook MailItem's SaveAs() method to save to a temp file and then read the file back in? I will need to transfer...

How can I use SQLIO Stress Test to define the max capacity of my SQL subsystem ?

I am looking for an article about Disk Subsystem Stress for SQL Server. So I can do better capacity management ! I already know the basis but I am looking for an "how to" for dummies who wants to install and do some reporting and trending using Excel ! Thanks ...

How to group elements by attribute values using XQuery on SQL Server?

Let's say I have a table in SQL Server which contains the results of a query with an inner join. The following XQuery: select @code.query ( 'for $s in /root/row return <Foo Language="{data($s/@lang)}" Method="{data($s/@method)}" Returns="{data($s/@returnType)}"> <Bar ReferencedBy="{data($s/@callers)}" Static="{data($s/@static)}" /> </...

The faster of two SQL queries, sort and select top 1, or select MAX

Of the following two queries, which is faster? 1 SELECT TOP 1 order_date FROM orders WITH (NOLOCK) WHERE customer_id = 9999999 ORDER BY order_date DESC 2 SELECT MAX(order_date) FROM orders WITH (NOLOCK) WHERE customer_id = 9999999 ...

I'm using SQL UDF's to encapsulate simple reporting/business logic. Should I avoid this?

I'm building up a new database in SQL Server 2008 for some reporting, and there are many common business rules pertaining to this data that go into different types of reports. Currently these rules are mostly combined in larger procedural programs, in a legacy language, which I'm trying to move over to SQL. I'm shooting for flexibility...

SQL Server parallels to Oracle Alter Table Set Column Unused?

Is there a parallel in Microsoft SQL Server (2005, preferably) for the Oracle functionality of setting a column to be unused? For example: ALTER TABLE Person SET UNUSED Nickname; Nothing turns up in searches, so my thought is this feature must be Oracle specific. ...

Update table a from table b where (conditions)

Evening all, Actually, it's night. About 11pm. My brain is shutting down and I need a bit of help so I can finish and go home :) I have two tables - table a and table b. I need to update a field in table a with the value from a field in table b when two other fields match. The tables don't have a unique id for each record :( Basica...

SQL Server Filestream - Delete "speed"

Hello, I'm working with the filestream datatype for the first time (SQL Server 2008) and I'm running into issues when I am doing some fast insert/deletes. Basically the speed at which the files are actually removed from the FileSystem is way slower then the insert/delete speed even if I invoke the garbage collector manually (As far as I ...

Configure VS2008 to create SQL Server databases instead of SQL Server Express?

Probably asked and answered before, but difficult to search for. In VS2008 when you right-click App_Data folder and create new database, it attempts to create a SQL Server Express database. Well I have SQL Server 2005 Standard installed and have thus uninstalled Express. How do I get VS2008 configured to know I want SQL Server database...

Creating a relational structure

Scenario: I have some MAIN_TABLE1 MAIN_TABLE2 these main tables are in relational schema. Now, I need to move the data from this relational schema to some other flat tables: flat_Parent_Table flat_Child_Table1 flat_Child_Table2 flat_GrandChild1 flat_GrandChild2 Now one record from MAIN_...

MySQL / SQL Server... working together as a total solution

Hi, I want to user sql server for analysis services, and a few other small apps. The majority of our systems are in MySQL. Things like user info, customer info, sales data I need to get into SQL Server. Obviously, there is much to debate here. What I was attempting to do is to dump a read only copy into SQL Server so I can user report...

Cannot connect to SQL Server Database

I cannot connect to SQL Server Database. I am trying to setup Membership with roles on my website using the MSDN Tutorial. It used to work only locally on my machine, however after following advice given on different forums, and on stackoverflow, the situation worsened, and now I can't even connect to the SQL Server Database. When I ru...

SQL Compact - Error executing multiple insert statements.

I'm using management studio to connect to my sql mobile/compact database. I'm trying to insert some dummy data into some tables, for example: INSERT INTO FlooringTypes (FlooringType) VALUES ('Carpet') INSERT INTO FlooringTypes (FlooringType) VALUES ('Smooth') However it returns the error: Major Error 0x80040E14, Minor Error 255...

How to debug stored procedures in sql server 2005

How can I debug stored procedures in SQL server 2005. ...

FORMSOF Thesaurus in SQL Server

Has anyone done any performance measures with this in terms of speed where there is a high number of substitutes for any given word. For instance, I want to use this to store common misspellings; expecting to have 4-10 variations of a word. <expansion> <sub>administration</sub> <sub>administraton</sub> <sub>aministraton</sub> <...

sql 2008 cursor difference with sql2000 ???

there is a difference between how the following code runs on sql2008 and sql2000. in sql 2000 the result is correct( the fetch is normal from the first row to the last row) while in sql 2008 the fetch is showing strange behavior( starts from the last inserted row till the first one. below is the code of the problem where 'area' is any ta...

Tips for improving performance of DB that is above size 40 GB (Sql Server 2005) and growing monthly by around 3GB

The current DB or our project has crossed over 40 GB this month and on an average it is growing monthly by around 3 GB. Now all the tables are best normalized and proper indexing has been used. But still as the size is growing it is taking more time to fire even basic queries like 'select count(1) from table'. So can u share some more po...

T-SQL copying a table variable

I'm trying to make a copy of a table variable: DECLARE @lt_Sections TABLE ( teamId SMALLINT NOT NULL ) DECLARE @lt_tempSections TABLE ( teamId SMALLINT NOT NULL ) -- populate some values in @lt_Sections -- take a copy of @lt_Sections SET @lt_tempSections = @lt_Sections This is giving me an error: Msg 137, Level 15, State 2, Li...

How to Optimize the Use of the "OR" Clause When Used with Parameters (SQL Server 2008)

I wonder if there is any wise way to rewrite the following query so that the indexes on columns get used by optimizer? Create Procedure select_Proc1 @Key1 int=0, @Key2 int=0 As BEGIN Select key3 From Or_Table Where (@key1 =0 OR Key1 =@Key1) AND (@key2 =0 OR Key2 =@Key2) END GO Even though columns in the W...

Linq Logical Delete with associations

Hi, I am trying to implement a logical delete senario across all my entities. All have an IsDeleted boolean property. I would also like to cascade the association deletes also. I started by adding a partial method for the entity to the datacontext. partial void DeleteQuestion(Question instance) { instance.IsDeleted = true; Exec...