sql-server

Calculate Percentage Applied Sql server 2008

Hi, A wrong percentage has been applied to a field (TotalPercentageAmount) and I need to correct it. Given 2 fields Amount and TotalPercentageAmount how can I calculate what percentage was applied? I need to work out percentage applied to TotalPercentageAmount and UPDATE the column with correct percentage. Little script I have created ...

ASP vs .NET database encoding issue

I have an old classic ASP application that stores information in a SQL Server 2008 database. I need to retrieve the information in a new .NET application but I am having some encoding issues. When I look in SQL Management Studio or at the data retrieved in .NET text strings looks weird when it contain Danish characters, e.g “Øvrige” wh...

a large paged GridView, Rollup and Grand Totals with SQLdataSource

If I get my dataset into a DataTable then I can do with it as I like, but I have the complexity of handling sort, paging and caching manually. I'm trying to avoid this for now. If I instead use a SQLdataSource that's all free. I need a grand total row, the contents of which I display outside the gridview. I know that I can get that b...

SQL query help, please

Hi there. I need help with building SQL query. I have 4 tables: Sellers, Goods, Projects and Sales. Sellers table has following structure: SellerID (int) PK SellerName (nvarchar) SellerStatus (int) SellerCity (nvarchar) Goods: GoodsID (int) PK GoodsTitle (nvarchar) GoodsColor (nvarchar) GoodsSize (int) GoodsCity (nvarchar) Proje...

Data Structures and their Database Mapping in .Net

Hello. From what I know, complex data structures (tree, binary tree, graph) are not available in the .Net Framework Base Class Library. Is there a good 3rd party library available for this purpose? Further, I need to map these data structures back to a physical database (SQL Server). Is such an extension available? I'd love to have a to...

What's the most efficient way to bulk-copy to SQL Server from Java?

I have data that is streamed from disk and processed in memory by a Java application and that finally needs to be copied into SQL Server. The data can be fairly large (hence the streaming) and can require up to several 100,000 rows to be inserted. The fastest solution seems to be using SQL Server's bulk-copy feature. However, I haven't f...

Filtering results based on many to many relationships

I'd like to filter the results of a query which returns the results from two tables which have any to many relationship to each other. Consider the following scenario: (SQL Server or MS Access) Table: Students --StudentID --StudentName Table: Grades --StudentID (Foreign Key) --CourseID (Foreign Key. Ignore for the sak...

sql scripting variable default value

I have a script file e.g. test.sql. I want to call this from another script, say caller.sql, in sqlcmd mode using :r test.sql. This works fine, but I want to use a scripting variable in test.sql. When I call test.sql from caller.sql I can set the scripting variable and all is well. However, I want to use a default value for the scrip...

Best paging solution using SQL Server 2005?

What is the most efficient paging solution using SQL Server 2005 against a table with around 5,000-10,000 rows? I've seen several out there but nothing comparing them. ...

How to get SQL Server CE TableAdapter to commit to database?

VS2008 project. Created local database (SSCE). Created dataset with tableadapter. Dragged dataset and tableadapter to the form so I can reference it in code. New records successfully add to the dataset but will not commit back to the database. Gives no error or clue why it won't work. TableAdapter insert statement was created autom...

Is there a view in SQL Server that lists just primary keys?

Hello, I'm working with SQL Server and trying to do a little "reflection," if you will. I've found the system view identity_columns, which contains all of the identity columns for all of my tables. However, I need to be able to select information about primary keys that aren't identity columns. Is there a view that contains data about ...

Get column names/types returned from a stored procedure

Is there a way via metadata (Information_Schema, perhaps?) to get a list of the columns a sproc will return? I'm trying to automate some code generation and that would help tremendously... ...

Database Design Foreign Keys

Two tables in my database are as follows: [Employee] Table: Id (Primary Key, Autoincrement) FirstName LastName Status [Status] Table: Status (Primary Key) Status is one of the following: "FullTime" "Contractor" "Terminated" How should [Employee].Status reference [Status].Status as foreign key? I see two ways of doing this: [E...

Calculate total score in SQL query from multiple tables

I have the following tables for a competition: User: Id Name Email EntryId Entry: Id Age Gender State GameResult: Id EntryId Duration Score QuestionResult: Id EntryId Correct UsersAnswer Each entry will have multiple games, and multiple questions. I need to perform a query that will find a list of the highest scores, and...

What benchmark to test how well my hardware for my C#.NET and SQL Server?

What benchmark would test how well my hardware rates, for my C#.NET and SQL Server ? I just like to know how good my hardware rates, for my software. ...

Is this a good place for a clustered index for ms sql 2008?

I have a database table that stores the file path of a file and a revision number. Each file has a revision number associated with it. Each file has about 10 revisions at any given time. Every day a new revision gets created for every file Every day the oldest revision gets removed for every file. There are about 100 Million file...

Individual index size for SQL Server

I can use sp_spaceused tablename to get the total index size for that table. But is there a way to get all indexes of that table's size individually? ...

SQL search for date between values or Min/Max if NULL

Hi, I have a T-SQL stored procedure where I want to search for a particular value and optionally limit the search to particular dates if they are passed in. If null values are passed in for either of these dates, then I want to ignore those. The way I am thinking of doing this by setting the input dates to minimum or maximum if they are...

C++ Failure on MSVCR80.dll using Microsoft.SqlServer.Management

Hi all, I am trying to run test on my server but it fails due to some C++ error coming from MSVCR80.dll. On my machine it runs smoothly but on the server, I do not find a way to make it work. Here is the error I have when running my tests (sorry it is in italian but it could be easily understood, I guess, everybody speaks italian, no?)...

Access 2007 to SQL server file upload?!

I have an Access 2007 database with an attachments facility. Currently the client may upload files locally but the files cannot be accessed elsewhere. I have been able to carry out a similar operation when developing on a web based system however I cannot seem to do it on an Access 2007 database and I am unsure as to whether it is even p...