sql

implementing complex algorithms on database stored information

Hey, I'm trying to figure out the best practice for implementing a complex algorithm on stored information in a relational DB. Specifically: I want to implement a variation of the k-means algorithm (a document clustering algorithm) on a large MS SQL Server database containing TFxIDF vectors of many documents (these vectors are used as ...

Alphabet Series Generation in SQL Server

Hi Team, I am trying to generate a series of alphabets, using SQL Server. Suppose I have a tables as follows DECLARE @Funding TABLE (FundingDetailID INT,FundingID INT, DetailDescription VARCHAR(50)) INSERT INTO @Funding (FundingDetailID ,FundingID , DetailDescription) VALUES (1,107,'Desc 1') INSERT INTO @Funding (FundingDetailID ,Fund...

sorting ACCESS sql query.

I made another thread which solved my problem, however I got the report reviewed and they want it a revision. I will do my best to explain: Consider the following: I just need the ORDER BY part of the sql query. The three fields are ACRNo, Type and Pty. I want it to sort by Type first. I then want it to sort by Pty. However, I wan...

Open databases from SQL Server like you do it with MySQL with PhpMyAdmin

i have a backup from a data base (SQL Server), i never worked with this type (always with MySQL and PhpMyAdmin to see the data). How can i see the data who is inside the backup? there is a Microsoft program to do that? like access. ...

Use sum in update statement where criteria

I have been trying to search for this and am not sure I am using the correct terms. Or it might just be that it's not possible. But what I am trying to do is update all records in a table that make up a sum value that is less than a set value. So here is an example: ID type amount received_date processed_date 1 debit 10 ...

How to get rid of label used but not defined

I'm trying to print the rows of a table in embedded sql. I have this code where publication is the table and pubid is the attribute. I tried this: EXEC SQL DECLARE C1 CURSOR FOR SELECT pubid FROM publication; EXEC SQL OPEN C1; EXEC SQL WHENEVER NOT FOUND GOTO close_c1; for(;;) { EXEC SQL FETCH C1 INTO :pubid; ...

How to make a .net dll stored procdure using VS2010 and SQL Server 2005?

Hi Does anyone have a tutorial on how to first make .net dll solution in VS2010 that will work for SQL Server 2005? I heard they have a special solution but I am not sure which one it is. I am trying to write what I think they call an extended stored procedure. Then a tutorial on how to actually right these extended stored procedures ...

Showing the most populous products in a table?

How would I show, for example, the 10 most populous products in a table? I have a sales table for example, that contains sales for 20 beers, 10 nachos, 5 peanuts, 2 hotdogs and 4 breakfasts. Is there a way to automatically calculate and see which is the most popular, and show them in descending order? edit: My table is as follows Ta...

SQL query ignoring where clause?

I have this query SELECT theMonth, sum( Sales ) AS sumSales, sum( Saleswotax ) AS sumSaleswotax, sum( Purchases ) AS sumPurchases, sum( Purchaseswotax ) AS sumPurchaseswotax FROM (SELECT date_format( saledate, '%M' ) AS theMonth, sales.cost AS Sales, ROUND( sales.cost * 0.85, 2...

adding a where clause from a separate table

I have a sales table, with fields product and cost of type varchar and decimal. I also have a purchases table, with fields product and cost, also of type varchar and decimal. lastly, I have a products table, with fields name, category and cost, of type varchar, varchar and decimal. I am doing the following query to get the NET income ...

mysql a query to show trend in views

I have a cron job that runs hourly. The cron job adds a record to table 'update' table - 'update' update_id (primary) timestamp and adds a record for each page of my website into table views table - 'views' page_id update_id view_count What I am looking to achieve is a query which can compare the most recent update (highest updat...

SQL Server version of Oracle's ADD_MONTHS()

In Oracle, you can use ADD_Months to add months on the fly in the sql statement. What is the MS SQL version. Oracle Example Select TestDate, TestFrequency, ADD_MONTHS(TestDate, TestFrequency) AS FutureTestDate FROM Tests Source : java's website ...

How to implement historical versioning?

We are in the early stages of building a large C# MVC2 app (we also employ Sharp architecture and Nhibernate as part of the ecosystem) on SQL 2008 R2, and one of the requirements is that all database row versions are accessible for a given period of history. We have toyed with the idea of a layout similar to: id (PK) recordId versionId...

Sql XML type with a specific schema

Can I have a table with an xml column but when inserting value into that column it has to match a specific schema? I'm using Sql Server 2005. ...

selecting distinct rows

I am trying to select distinct but its not working SELECT Distinct `table1`.`myID` AS `myID`, `table1`.`TypeID` AS `TypeID`, Is there any thing I am missing? ...

Grouping by not working correctly

I have a guests table, with fields name and country, both varchar. At the moment, I have two records, one with country being USA, and one with country being USA. I am trying to group my records and then order them to see the most populous. I first tried this: SELECT * FROM ( SELECT count( country) AS countryCount, country FROM guests...

Utilizing all Cores in SQL Sever Machine when calling SPs from C# program

Hello, I have a simple single threaded utility written in C# that inserts data into SQLServer DB using SP calls. The SQL Server machine has 8 core processor. The problem is that the utility is running very slow and 4 of the cores show max utilization in task manager and other 4 are not utilized at all. We also tried running multiple ...

Add Sort Order for FOREIGN KEY CONSTRAINT on SQL Server

How do I add the Foreign Key Sort order in the following statement: ALTER TABLE [dbo].[ActionLog] WITH CHECK ADD CONSTRAINT [FK_ActionLog_Order] FOREIGN KEY([OrderID]) I want the OrderID to be descending. ...

Code Alignment In SQL Server 2008?

I am using SQL Server Management Studio.I want to know the shortcuts for easily aligning the T-SQL Queries similiar to ctrl+k+d in visual studio. ...

Getting PHP variables and their values from SQL COUNT() and GROUP BY

I'm trying to extract and make variables out of the "thinking skills" (like analyzing, evaluating, etc.) from a test and set their value to the number of test items within each. I'm stuck, so any help would be appreciated. (The SQL statement seems to work fine.) Example of what I want: $analyzing = 7, $applying = 13, etc.... Thanks! ...