Tag: database

SQL Server restore and backup per schema

Possible Duplicate: SQL Server 2005 restore one schema only I have a database that contains several schemas in SQL Server 2008 R2. All schemas contain the same tables. Now I want to be able to restore a backup of only one schema, while leaving the other schemas the way they are. I’m looking for something […]

How to add a counter to a recurring dataset in SQL?

I have a table which has a recurring field. I need a function to count and say which recurrence is in nth line. i.e.; If the table is as follows; ID NAME CLASS 1 Tom a 2 Dick b 3 Harry c 4 Marry b 5 Bob c 6 Mat c 7 Mandi a A […]

Custom Result Order using UNION – TSQL

I have a fairly simple task in which I need to select rows with a particular field with a value of 1 first, then a value of 2 and finally all other rows with a value of 0. I using a join to get which items are a member of which category. I thought that […]

how to put words into a variables and check if it matches the data in database

I am using MSSQL and C# to write a search engine. I got a bunch of stop words in the database. In my default.aspx page, I got a textbox and a search button. Users can type in a whole sentence into the textbox. I wrote the code for searching a single keyword but not a […]

Best pattern for storing (product) attributes in SQL Server

We are starting a new project where we need to store product and many product attributes in a database. The technology stack is MS SQL 2008 and Entity Framework 4.0 / LINQ for data access. The products (and Products Table) are pretty straightforward (a SKU, manufacturer, price, etc..). However there are also many attributes to […]

Securing access to SQL Server data

I’m building a Windows application that will go against a SQL 2008 database. Some of the table data is very sensitive but some of our users will still need at least read if not read/write access to those tables. We’re going to use Windows Security to control their access to the database. I want to […]

Migrating a SQL Server test database from development to test environment with a script?

I’m doing a lot of development with a weekly demo to client. I have a development environment and a test environment. Every week I have to backup the database on development and then use remote desktop to restore it on the test server. I’ve tried using MSdeploy to move the database but haven’t been able […]

Grouping by an alias

SELECT COALESCE (rsu.last_name + ‘, ‘ + rsu.first_name + ‘ ‘ + rsu.middle_name + ‘.’, rsu.last_name + ‘, ‘ + rsu.first_name) as student_name, rsu.day_id FROM roster_school_unattended rsu GROUP BY student_name ORDER BY rsu.day_id does not work. What’s the most elegant workaround? EDIT: The result-set should have something like this Muster, Hans | 2011-11-01 Muster, Hans […]

Generic SQL for update / insert

I’m writing a DB layer which talks to MS SQL Server, MySQL & Oracle. I need an operation which can update an existing row if it contains certain data, otherwise insert a new row; All in one SQL operation. Essentially I need to save over existing data if it exists, or add it if it […]

Query a Subquery

I have to display the Rank of a user for which I plan to use the Rank() function in SQL Server. The Sql query to get the rank is as follows select a.user_id, RANK() OVER (ORDER BY (a.quant_points) DESC) AS QRANK, RANK() OVER (ORDER BY (a.verbal_points) DESC) AS VRANK, RANK() OVER (ORDER BY (a.dilr_points) DESC) […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.