sql-server-2008

Query Execution time in Management Studio & profiler. What does it measure?

I have my production SQL Server in a remote data center(and the web servers are located in the same data center). During development we observed that one particular view takes a long time to execute (about 60-80 secs) in our local development SQL Server, and we were OK with it.It was promoted to production and when I run the same query o...

SQL Server 2008 R2 - Table Designer

Did Microsoft remove the graphical table designer from SQL Server 2008 R2? I'm using it to connect to SQL Azure and I'm not getting the nice graphical designer from 2005. I was wondering if this is a SSMS R2 thing or an Azure thing. Thanks! ...

List number of rows per field value in SQL

Hi, database/SQL novice here. I have a table with a column called, for example, "EmployeeID". I want a query that will, for each distinct employeeID, return the number of rows that have that as their ID. I hope it's clear what I'm trying to do and someone will know how to help! I don't think it should matter, but just in case, I'm usin...

What is a "schema provider" in an RDBMS?

Could someone please define what is meant by a schema provider? I'm familiar with DB schema (in this context, I take them to mean a named, logical container for DB objects). Why would a schema provider be useful? From a high level, how do they operate? The context here is SQL Server 2008. ...

SQL Query to return values of a particular column concactenated with comma (,)

Possible Duplicate: How do I Create a Comma-Separated List using a SQL Query? ItemName | DepartmentId --------------------- Item1 | 21 Item1 | 13 Item1 | 9 Item1 | 36 Item2 | 4 Item2 | 9 Item2 | 44 I need to display all the department Id's that require a particular Item using SQL Querie...

SQL query that applies aggregate function over another aggregate function

I have several query results that use one or more aggregate functions and a date GROUP-BY so they look something like this: Date VisitCount(COUNT) TotalBilling(SUM) 1/1/10 234 15765.21 1/2/10 321 23146.27 1/3/10 289 19436.51 The simplified SQL for the above is: SELECT ...

SQL Server 2008 - How do i return a User-Defined Table Type from a Table-Valued Function?

Here's my user-defined table type... CREATE TYPE [dbo].[FooType] AS TABLE( [Bar] [INT], ) This is what ive had to do in my table-valued function to return the type: CREATE FUNCTION [dbo].[GetFoos] RETURN @FooTypes TABLE ([Bar] [INT]) INSERT INTO @FooTypes (1) RETURN Basically, im having to re-declare my type definition in the RETU...

SQL Server Profiler issue

Hello everyone, I am using SQL Server 2008 Enterprise and I want to use SQL Server profiler to capture deadlock event only. And when deadlock occurs and event captured, I will stop SQL Server profiler. My question is, since I launched SQL Server profiler, and before deadlock occur (event captured), any impact (more about performance im...

unable to connect sql with visual studio c#

i am unable to connect my program of visual studio c# with sql data base i think the i m missing any library can any one help plzzzzz.... ...

SQL Server 2008 on a separate machine is very slow

We have an application which gets the data from a MS SQL database residing on a server in the headquarter over an internet connection. Now the problem is that the data is pretty large which makes the query to take large time to transfer the data from the head quarter to the client. Does SQL provide anything method to speed up queries i...

How to do a partial copy of a remote SQL Server Express database to a local SQL Server Express database?

I'm in a situation where I need to create a partial copy of a database from a remote SQL Server (2005/2008 Express Edition) and store it in a local SQL Server (2005/2008 Express Edition) database. The local copy will have the same schema definition, but contain only parts of the data from the remote database. The local database has to ...

how i can backup all database (sql server 2008) in C# code ?

hi i have database on computer 1 (sql server 2008) and i have sql server 2008 on computer 2 i need any sample code in C# that i can backup database on computer 1 to computer 2 thank's in advance ...

Complex sum with grouping

Hi I have table called Games with columns: Player1Id, Player2Id, Player1Points, Player2Points. Sample data: Player1Id Player2Id Player1Points Player2Points --------- --------- ------------- ------------- John Piter 4 1 John Adam 2 10 Piter Adam ...

Restore DB from one server to another by sql-script

Are there any way to restore db from one server to another, if I know other server IP address? Can I do it by sql-script or some wizard? I use MS Sql Server Managment Studio 2008 ...

Create Trigger to log SQL that affected table??

I'm trying to find out what is updating the value of a column and i have very little knowledge of the application. At a quick glance I've noticed about 90% of the applications business logic is handled on the database. Needless to say the depth of SP's, functions, and triggers is crazy. I'd like to create a trigger on the table in quest...

Creating Database Mocks in ASP.NET MVC using Data from Existing Database

I have an existing ASP.NET MVC application with some sample data in the SQL Server database, which is working fine.. Assuming I have all of the necessary repositories and IOC in place, is there a tool that will extract the data from a group of tables, and "freeze-dry" it into a mock object (perhaps using an XML file to store the data)...

SQL Server 2008 backup tutorial

Hello everyone, I am using SQL Server 2008 Enterprise. I am looking for a database backup tutorial for a newbie. There are some good documents on MSDN which are about backup theories (e.g. different types of backup). What I am looking for and asking here is a step-by-step tutorial which is more practical (e.g. describe which option in G...

Inserting data into a sql server 2008 table

Is there a relatively simple way to insert multiple rows into a table in which the data being inserted comes from both a select statement and hard-coded data? For example, insert into tblB (field1, field2, field3) values ( 950, select fieldA, fieldB from tblA ) ...where 950 is a hard-coded value and fieldA and fieldB come from...

SQL Server - need a SQL Query to identify/highlight specific changes in an audit table

Say I have some data stored in an audit table, where triggers on the main data table write all invoice record updates to this audit table. The audit table contains this data: InvoiceID CustomerID ItemSold AmountSold SalesPerson ModifyDate 1001 96 Widget 800 Robert 2001-1-1 1006 85 ...

FREETEXTTABLE always has a rank of 0

I'm using SQLServer 2008 and if I perform the following query: SELECT * FROM FREETEXTTABLE(SomeTable, Name, 'a name that I know exists') I get the rows back that I would expect, but the rank is always 0. Searching for a solution to this problem, I found this question on the Microsoft ASP.NET forum, and sure enough if I add: ALT...