I'm trying to get the top N records for each unique row of data in a table (I'm grouping on columns b,c and d, column a is the unique identifier and column e is the score of which i want the top 1 in this case).
a b c d e
2 38 NULL NULL 141
1 38 NULL NULL 10
1 38 1 NULL 10
2 38 1 NULL 1
1 38 1 ...
In SQL server 2008:
Suppose I have two tables.
Table1 has 3 fields: Name, Date1 and Date2. Currently, all the Date2 entries are NULL. (Name, Date1) form a unique key.
Table2 has 2 fields: Name and Date2. (Name, Date2) form a unique key.
Every "Name" in Table1 has at least one corresponding entry in Table2.
Now, I want to update all...
I would like to user SQL Server 2008 for my public web site.
It will be installed on a quad-core CPU and it will be used only through several web applications installed on the same server.
My options are:
Per-CPU license - around 5-6k US$
Per client - around 1k US$ + cost per client
Now, I don't understand the second model. I have ...
I need to grant a db_datawriter before executing SqlBulkCopy and remove it after:
try
{
"EXEC [db_mod].[sys].[sp_addrolemember] N'db_datawriter', N'my_user'" // via SqlCommand
bulk.WriteToServer(table);
}
finally
{
"EXEC [db_mod].[sys].[sp_droprolemember] N'db_datawriter', N'my_user'" // via another SqlCommand
}
but I'm getti...
Hello, please can someone help.
I have two datasets I'm working with and two tables. I've managed to do one expression correct so do not understand why my second won't work.
My first expression is where I need to state the target number based on a result e.g.
=IIF(Fields!Line.Value = "B1", "10", IIF(Fields!Line.Value = "C1", "15", ""...
I have successfully set up FILESTREAM on my SQL 2008 server; however I've noticed that even when I have deleted rows containing FILESTREAM data, the physical data file doesn't seem to get deleted.
By the physical file, I mean the file in SQLServer's managed directory with a uniqueidentifer as the filename not the original file added to ...
I am using an Openquey which has been working fine on SQL Server 2005, I have 1 server that is SQL Server 2008 which this does not work on.
If I run the following:
SELECT *
FROM OPENQUERY([Manchester],
'[Manchester].[PilotWebApp].[DBO].rsp_HandheldPerformance ''10/01/2009'',
''10/10/2009''')
I get this error:
Cannot ...
After having a period of logshipping failures going unnoticed (due to a stopped SQL Agent on the secondary server) I'm looking at configuring some monitoring.
Having seen the ability to specify a "Monitor Server instance" on the SQL Server 2008 log shipping setup and the relavant MSDN docs (http://msdn.microsoft.com/en-us/library/bb5107...
I have web application which we deployed in a production .
We have separate servers for WEB and Database. The DB is SQL Server 2008 and it is hosted on a completely different server and we have our IIS installed on a different server.
On my web server, we get following error.
Could not load file or assembly 'Microsoft.SqlServer.Types, V...
I need to setup an application to scan a barcode from a packing slip and the associated fulfillment items on a windows CE 5.0 device and update the inventory on the server. I'm using VB.NET. However, what is the best way to interact with the database? Integration Services, ADO.NET, RDA... etc... it's a bit overwhelming trying to figur...
I am using SQL Server 2008 express edition and its collation settings are set to default.I wish to store special characeters like á ,â ,ã ,å ,ā ,ă ,ą ,ǻ in my database but it converts them into normal characters like 'a'. How can I stop SQL Server from doing so?
...
I have the following SQL. Tables defined.
#tbContinent
--------
ContinentID | ContinentName
AddressInCountry
--------
AddressID | CountryID
AddressInContinent
--------
AddressID | ContinentID
NameInAddress
--------
AddressID | NameID
I then have the following SQL:
--- Insert into tbName
DECLARE @tbName TABLE
([ID] int, [Add...
Hi.
I have a Name table with the columns
NameID
Name
TypeID
With the following SQL
SELECT[NameID]
FROM[Name]
WHERE[TypeID] = @TypeID
AND NameID >= (SELECT MIN([NameID])
FROM [Name]
WHERE [Name]='Billy' AND [TypeID]=@TypeID)
Ive been asked to convert this to an Inner Join without using any nested select but n...
Hi All,
I will be writing a query to achieve something like below, please help me
TableName: Application
AppId (PK,int) AppType (bit)
1 0
2 0
3 0
4 0
5 1
6 0
7 0
8 0
9 1
10 1
11 0
12...
I need to change the collation of an nvarchar variable. By documentation:
(...)
3. The COLLATE clause can be specified
at several levels. These include the
following:
Casting the collation of an
expression. You can use the COLLATE
clause to apply a character expression
to a certain collation. Character
literals a...
Get XML schema from database schema (SQL Server 2008 diagram)
I am using SQL Server 2008. Is their is a way to do this in the SQL studio enterprise manager?
Rather than write code or use an external tool
...
I'm trying to practice using the ASP.NET MVC at home, but I ran into an impossible problem. I cannot open a connection to SQL Server 2008, I get this error: "Connections to SQL Server files (*.mdf) require SQL Server Express 2005 to function properly. ..."
I've googled around for numerous responses, none of them either working or addres...
I have to cache an object hierarchy in-memory for performance reasons, which reflects a simple database table with columns (ObjectID, ParentObjectID, Timestamp) and view CurrentObjectHierarchy. I query the CurrentObjectHierarchy and use a hash table to cache the current parents of each object for quickly looking up the parent object ID,...
In SQL Server 2008, I want to represent an integer as a 3-character string - so:
3 becomes '003'
5 becomes '005'
107 becomes '107'
How can I do this?
...
Hi,
I have the following 'circular dependency' in my Inner Join, any ideas how to get round it?
SELECT *FROM Reference
INNER JOIN ReferenceInActivity ON Activity.ActivityID = ReferenceInActivity.ActivityID
INNER JOIN @tbActivity AS Activity ON ReferenceInActivity.ReferenceID = Reference.ReferenceID
I get the error:
Msg 4104, Level 1...