sql-server

How to version SQL Server schema using VS 2005?

I am new to C# programming and am coming to it most recently from working with Ruby on Rails. In RoR, I am used to being able to write schema migrations for the database. I would like to be able to do something similar for my C#/SQLServer projects. Does such a tool exist for the VS 2005 toolset? Would it be wise to use RoR migrations...

How to debug SqlDataSource

I'm testing my site against SQL injection attacks and I would like to trace SqlDataSource messages sent to SQL server. How can I do that or at least get as close as I can. ...

Is AWE in SQL 2005 Ent needed on 2003 32-bit w/ 24GB?

I have a WS 2003 32-bit system running SQL Server 2005 Enterprise with 24GB of RAM. The /PAE switch is enabled. Can SQL now use the 24GB or does AWE need to be enabled? ...

SQL Server architecture guidance

Hi, We are designing a new version of our existing product on a new schema. Its an internal web application with possibly 100 concurrent users (max)This will run on a SQL Server 2008 database. On of the discussion items recently is whether we should have a single database of split the database for performance reasons across 2 separate ...

Byte to Integer in c#

I am reading a row from a SQL Server table. One of the columns is of type tinyint. I want to get the value into an int or int32 variable. rdr.GetByte(j) (byte) rdr.GetValue(j) ...seems to be the only way to retrieve the value. But I can't figure out how to get the result into an int var. ...

Long-running Database Query

I have a long-running SQL Server 2005 query that I have been hoping to optimize. When I look at the actual execution plan, it says a Clustered Index Seek has 66% of the cost. Execuation Plan Snippit: <RelOp AvgRowSize="31" EstimateCPU="0.0113754" EstimateIO="0.0609028" EstimateRebinds="0" EstimateRewinds="0" EstimateRows="10198.5" Log...

What is the corrrect way to increment a field making up part of a composit key

I have a bunch of tables whose primary key is made up of the foreign keys of other tables (Composite key). Therefore the attributes (as a very cut down version) might look like this, please note that I am only showing the attributes that make up the key - there would be and are other attributes that are stored alongside the composite ke...

Need a set based solution to group rows

I need to group a set of rows based on the Category column, and also limit the combined rows based on the SUM(Number) column to be less than or equal to the @Limit value. For each distinct Category column I need to identify "buckets" that are <=@limit. If the SUM(Number) of all the rows for a Category column are <=@Limit then there w...

Getting filtered results with subquery

I have a table with something like the following: ID Name Color ------------ 1 Bob Blue 2 John Yellow 1 Bob Green 3 Sara Red 3 Sara Green What I would like to do is return a filtered list of results whereby the following data is returned: ID Name Color ------------ 1 Bob Blue 2 John Yellow 3 Sara Red i.e. I would ...

Performance of stored proc when updating columns selectively based on parameters?

I'm trying to figure out if this is relatively well-performing T-SQL (this is SQL Server 2008). I need to create a stored procedure that updates a table. The proc accepts as many parameters as there are columns in the table, and with the exception of the PK column, they all default to NULL. The body of the procedure looks like this: CRE...

When are database triggers bad?

Possible Duplicate: Are database triggers evil? There is lot of negative information on database triggers, just want to get the community's take on when is it good vs bad. ...

How do I add a variable to column2 when column1 is a specific value

How can I do a search for value A in column1 and add a value B in column2? In other words for every record that column1 has the value A I want to make the value in column2 = B (Currently column2 is empty) Would this work? UPDATE MyTable SET Column2 = REPLACE(Column2,NULL,'B') WHERE Column1 = "A" ...

Synchronizing an ERWin model with a Visual Studio 2008 GDR 2/2010 db project

I am looking for options to get our vast collection of DB objects across many DBs into source control (TFS 2010). Once we succeed here, we will work toward generating our alter scripts for a particular DB change via TFS build. The problem is, our data architecture group is responsible for maintaining the DB objects (excluding SPs), and ...

SQL Express vs SQL Plus

Hi, I'm wondering what the difference is if any between SQL Express and SQL Plus. I know SQL Plus is used with Oracle but not sure if SQL Plus is a modification of SQL Express or a totally different installation. Thanks ...

INSERT SELECT Statement and Rollback SQL

Im Working on a creation of a query who uses INSERT SELECT statement using MS SQL Server 2008: INSERT INTO TABLE1 (col1, col2) SELECT col1, col2 FROM TABLE2 Right now the excecution of this query is inside a transaction: Pseudocode: try { begin transaction; query; commit; } catch { rollback; } If TABLE2 h...

sql server: permissions on table

SQL Server 2008 : How do I find out what kind of roles have what kind of permissions on a given table. Thank you in advance. ...

SQL Server Data Import with a "lookup"-- Hopefully a Simple Question

I have two databases, on two separate SQL Servers (trying to consolidate both). This is my setup, and I'm trying to import from Server1:Orders table to Server2:Orders table. Server1 Database1 Orders(ID, CustomerName, DateOrdered) Server2 Database2 Customers(ID, Name) Orders(ID, CustomerID, DateOrdered) ...

How to execute .sql file in SQL server 2000/2005/2008

When get a .sql file, how do you execute it? Double click to open it and press F5? Is there any other way to execute it and also able to see the execution result. Thanks. ...

SqlCE DB occasionally freezes on one handheld, not another

I have two types of custom handhelds which are similar, but slightly different, each running the same WinForm application and a WinCE database: Type 1: WinCE 4.2, 400 mhz, 93244 kb Type 2: WinCE 5.0, 520 mhz, 84208 kb Type 1 will happily proceed through a large batch db operation (initiated by the app), by Type 2 will consistently begi...

sql-server performance optimization by removing print statements

We're going through a round of sql-server stored procedure optimizations. The one recommendation we've found that clearly applies for us is 'SET NOCOUNT ON' at the top of each procedure. (Yes, I've seen the posts that point out issues with this depending on what client objects you run the stored procedures from but these are not issues...