sql

Can't Create ActiveX Control

Hey Everyone, Working on getting a legacy app up and running again for work. I'm getting an error at run time that I can't create an activeX control. The suspect call is oSQL = CreateObject("SQLDMO.SQLServer2") I did a bit of googling and found that SQLDMO should be in a SQLDMO.dll. I've got that DLL referenced in my project but it i...

excel to oracle db using VS 2005 C#

I want to build a utility that can import data from excel sheet(columns are fixed but sheets can be any number) to oracle db. Can you suggest how should I: Read excel sheets(n number)?(Best way) Validate data? Bulk insert into DB? My concern is performance here. Each sheet can have 200,000+ rows. PS - please remember I am a complet...

How to create index for dynamic search strings

I have a little DB, for academic purpose only, and I have object tables at most. I've created a entity-relationship model (ERM) in Power Designer and the program, by default, creates index for the serial id's for each table. I want to know how do I use a index like that on a query.Say I would want to find a product by its id, but using...

Visual Studio 2008 (C#) with SQL Compact Edition database error: 26

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Ser...

one record from each group?

Say I have a table like this: x1 | y1 | x2 | y2 | area | color 5 | 0 | 5 | 0 | 1 | r 5 | 0 | 6 | 0 | 2 | g 5 | 1 | 5 | 0 | 2 | b 5 | 1 | 5 | 1 | 2 | r 5 | 2 | 5 | 0 | 3 | g 5 | 2 | 5 | 1 | 3 | b How can I construct an SQL query so that the resulting table has one of r, g, b (each having the ...

SQL Server Int or BigInt database table Ids

I am writing a new program and it will require a database (SQL Server 2008). Everything I am running now for the system is 64-bit, which brings me to this question. For all of the Id columns in various tables, should I make them all INT or BIGINT? I doubt the system will ever surpass the INT range but it is a possibility within some of t...

How to return the count of related entities in sqlalchemy query

I'm new to sqlalchemy, and while the documentation seems fairly thorough, I couldn't find a way to do quite what I want. Say I have two tables: forum and post. Each forum has a parent forum, and any number of posts. What I want is: A list of top-level forums Eagerly loaded child forums accessible through the top-level forums A count o...

What sort of database design would I need to use in case I wanted users to save tags, and be able to call already used tags?

I'm trying to implement a feature similar to StackOverflow's tag feature. That a user can create a new tag, or by typing pull up a list of similar tags already created. This is such a wonderful feature on this site and I find it sad that most sites do not have something like this. It's both robust, and yet very very flexible and best of...

simple encryption technique for mysql using php

How to encrypt user password in php. please explain in a way a beginner can understand. I already have this sample code: $password="john856"; $encrypt_password=md5($password); echo $encrypt_password; Can you help me incorporate it in my current code, which does not do any encryption. <?php $con = mysql_connect("localhost","root...

If I have two tables in SQL with a many-many relationship, do I need to create an additional table?

Take these tables for example. Item id description category Category id description An item can belong to many categories and a category obviously can be attached to many items. How would the database be created in this situation? I'm not sure. Someone said create a third table, but do I need to do that? Do I li...

Ruby on Rails: joining two tables on something other than the standard foreign key

I have a rails query like: @user = User.find_by_username(params[:search], :include => [:user_similars]) Models: user (has_many :user_similars), user_similar (belongs_to :user) The user_similars mysql table has a "user_id" field as a foreign key, but I don't want :include to join on that for this instance. I'd like to join on...

SQL Cursor value in single group

I am using a SQL cursor. I want to select the values Eg:- While(@@fetchstatus ==0) BEGIN if(cond) SELECT rownumber, rowname FROM TABLE END ANSWER:- During the first round of execution of While loop I am getting the value. 1,"Firstrow"(From Row select) Next 2,"SecondRow" All these values are displayed in my output as separa...

Random ID Generator, mapping vs. same-column

Hi all, There're a few entities that we wish to hide its exact ID from the customers - the main reason is that, we do not want customers to know how many of them are in the DB. e.g. from the URL, http://mydomain/user/get/27, it says that this is the 27th user. Therefore, I am implementing a solution that assigns random ID (that has to...

Cursor in While loop

My Cursor and Output SET NOCOUNT ON DECLARE @vendor_id int, @vendor_name nvarchar(50) DECLARE @subvendor_id int, @subvendor_name nvarchar(50) PRINT '-------- Vendor Products Report --------' DECLARE vend_cursor CURSOR FOR SELECT * FROM MYSEQ OPEN vend_cursor FETCH NEXT FROM vend_cursor INTO @vendor_id, @vendor_name WHILE @@FETCH_S...

What's wrong with this query?

Someone help me: $query = "INSERT INTO tbl_users(user, password, password_def, userid, level , regdate, lastdate, email) VALUES('$username', sha1('$password') , sha1('$password'), '$userid', '0', NOW(), NOW(), '$email');"; $userid is a ramdon md5 id. It gives me this error: posttokenError: Account not created ...

if-else, case or decode inside of a ref cursor

Hi there, I have this big code where I want 3 things in my search: 1- look for all the orders (delivered and not) that match the search: 2- look for all the pendent orders that match the search; 3- look for all the delivered orders that match the search; create or replace function search_order(search IN VARCHAR2, a_option NUMBER) R...

Converting mysqlpp::String to C++ int

Ok, I'm relatively new to using the mysqlpp library that is used in Visual Studio to connect to a MySQL database and am having trouble trying to convert a vector of type mysqlpp::String to a vector of type int. Does anyone have any experience with mysqlpp and would mind helping me out a little? I've posted an example of what I'm basicall...

Bulk DELETE on SQL Server 2008 (Is there anything like Bulk Copy (bcp) for delete data?)

Is there any solution for bulk delete in SQL Server? I can't use TRUNCATE because I want to use WHERE for limiting the rows in action. Is there anything like Bulk Copy (bcp) for delete data? ...

New Sql query solution

person_id | manager_id | name | | | | ------------------------------- I have to display name of every person with manager name. Yes its complete table. Thats all I have. ...

Sql query for this?

person_id | manager_id | name | | | | ------------------------------- Query to find name of manager who supervises maximum number of employees? Added: This is the only table. Yes self-referencing. DB is mysql. Recursive queries will also do. ...