sql-server

Does SQL Server guarantee sequential inserting of an identity column?

In other words, is the following "cursoring" approach guaranteed to work: retrieve rows from DB save the largest ID from the returned records for later, e.g. in LastMax later, "SELECT * FROM MyTable WHERE Id > {0}", LastMax In order for that to work, I have to be sure that every row I didn't get in step 1 has an Id greater than Last...

SQL Server 2005 Data Encryption And LINQ TO SQL

I have a ASP.NET MVC application and I have used Linq-to-SQL queries to get data from my SQL Server database. Now for security purposes I need to encrypt my database. How does Linq-to-SQL work with encrypted databases? ...

Reseeding the Identity column for new records only (SQL)

I have data in a table, but am working on data loading. I want to reseed all new inserts for testing. What would be the line to set all new inserts to a certain seed value? ...

Save objects to a database?

So far in my .Net coding adventures I've only had a need to save information to files. So I've used XmlSerializer and DataContractSerializer to serialize attributed classes to XML files. My next project, however, requires that I save and retrieve information from a SQL server database. I'm wondering what my options are for doing this. T...

Move row from one table to another?

I have two tables with the same column definitions. I need to move (not copy) a row from one table to another. Before I go off and use INSERT INTO/DELETE (in a transaction), is there a smarter way? SQL Server 2005 ...

transactions in MS Access

Let's say I have the following code in a form that is triggered on some click event. DoCmd.SetWarnings False DoCmd.OpenQuery "AddSomeStuff" DoCmd.OpenQuery "UpdateSomeOtherStuff" DoCmd.OpenQuery "DeleteABunchOfCrap" DoCmd.SetWarnings True Can I assume that the three update queries I executed (in SQL Server) are not transactional in th...

Converting rows to Columns in SQL

I have a table (actually a view, but simplified my example to a table) which gives me some data like this CompanyName website Google google.com Google google.net Google google.org Google google.in Google google.de Microsoft Microsoft.com Microsoft live.com Microsoft bing...

Use SQL to clone a tree structure represented in a database

Given a table that represents a hierarchical tree structure and has three columns ID (Primary Key, not-autoincrementing) ParentGroupID SomeValue I know the lowest most node of that branch, and I want to copy that to a new branch with the same number of parents that also need to be cloned. I am trying to write a single SQL INSERT IN...

How do I determine the server's MAXDOP setting in SQL Server?

I see lots of sites that show how to set it, but I just want to see what it is first. What is the command to do this? ...

Fixing an SQL where statement that is ugly and confusing

I am directly querying the back-end MS SQL Server for a software package. The key field (vehicle number) is defined as alpha though we are entering numeric value in the field. There is only one exception to this, we place an "R" before the number when the vehicle is being retired (which means we sold it or the vehicle is junked). Assumin...

Alternatives to Streaminsight in the .NET world

Streaminsight was released as part of SQL Server R2, kind of a strange departure but interesting concept. However, it doesnt appear to be anything particularly groundbreaking so I wondered if there were any existing open source .NET libraries that could be considered alternatives to StreamInsight. ...

SQL Server 2005 config file path of databases loaded

I need to find the path of the database (MDF) or at least the database logs loaded but for some reasons I cannot login through the SQL Server so I need to know if you know any file/config file that keeps the path of the databases or log file . ...

tsql to know when dbcc checkdb was run on a database last time

Hi, Using Tsql, how can i know when DBCC checkdb was last run on SQL server (2000, 2005 or 2008)? Regards ...

Best optimizing for a large SQL Server table (100-200 Mil records)

What are the best options/recommendations and optimizations that can be performed when working with a large SQL Server 2005 table that contains anywhere from 100-200 Million records? ...

Tsql, know when index rebuild, reorg or updatestatistics was last run on SQL server

Hi Using Tsql, how can i know when Index rebuild, reorg or updatestatistics was last run on SQL server (2000, 2005 or 2008)? Regards ...

How to parse xml in sql server to process NULL value in DateTime DataType.

I have created a sample query in sql server to parse data from xml and to display it right now. Although I will be inserting this data in my table but before that I am facing a simple problem. I want to insert NULL in datetime field ADDED_DATE="NULL" as shown in xml given below. But when I executes this query. It gives me error Convers...

Is it possible to set a SQL server columns' description using a fluent nhibernate map?

I am using my fluent nhibernate mappings to generate my MS SQL Server database. I would like to be able to set a columns' description as part of this generation. ...

SQL Server to PostgreSQL

I need to create a trigger in SQL Server. Trigger works: If I found new line where T = 'A'; then add this line to PostgreSQL table. Is it possible to create it, without software? (I know how to create trigger, but how to create connection between two servers? ...

SQL Server problems when using ODER BY and DISTINCT together

I got two problems, the first problem is my two COUNTS that I start with. GroupID is a string that keep products together (Name_Year together), same product but different size. If I have three reviews in tblReview and they all have the same GroupID I want to return 3. My problem is that if I have three Products with different ProductID b...

SQL Server double to decimal read problem

Hi, from front end application I am sending the value as 0.15 to database via a stored procedure, but it gets stored as 0 value. Why? please guide. I am using C# + ASP.NET + SQL Server 2008 ...