sql

Dynamic Datasource in SQL Server Stored Procudure

I have a SQL Server that houses Several Databases. I have a Main Database that holds several tables with entities and ID numbers. Then, each one of those entities has a correlating database (not a table, but database) with all of its information. For example, if the an entity in the MAIN database has an ID number of 1, there would be an ...

Tokens for SQL statement fill in blank instead of NULL making it crash...

I have a sql statement like this: DECLARE @MyVariable as varchar(50) SET @MyVariable = $(TokenValue) In this the $(TokenValue) will fill in a value from a form (ignore how it's doing it, it's not important, just that if there's a value in the field it relates to it'll get filled in there). If The field in the form was left blank howev...

Concatenate row values T-SQL

I am trying to pull together some data for a report and need to concatenate the row values of one of the tables. Here is the basic table structure: Reviews ReviewID ReviewDate Reviewers ReviewerID ReviewID UserID Users UserID FName LName This is a M:M relationship. Each Review can have many Reviewers; eac...

Trying to initialize 2 values in 2 variables using 1 query, is it possible to do this. ?

SET @Password = ( SELECT UserPassword,IsLocked FROM [Authentication].[tblLogin] WHERE UserName=@UserName) i m trying to get both values userpassword and islocked in two variables to be used in same SP in next query. Is it possible or do i have to write two queries for this. Is it there a concept of arrays in sql server ...

web form insert and trigger before insert

I have a oracle table called: create table InsertHere( generate_id varchar2(10), name varchar2(100) ); I have to insert data in this table from a web from. In the web form there are two elements: type and name . I have to generate 'generate_id' from the type user has selected. Task : Before insert into the Insert...

SQL Server Delete on read

Is there an easy way in SQLServer touse data as READ_ONCE? What I mean is, can I set it to delete a row after it has selected it? ...

if function inside sql query?

function get_tags_by_criteria($gender_id, $country_id, $region_id, $city_id, $day_of_birth=NULL, $tag_id=NULL, $thread_id=NULL) { $query = "SELECT tags.* FROM tags, thread_tag_map, threads WHERE thread_tag_map.thread_id = threads.id AND thread_tag_map.tag_id = tags.id AND threads.gender_id = $gender_id ...

Group events by temporal distance in SQL

In general, I need to associate (group) records which are created in similar time periods. If it helps, thinking of the example below as clickstream data where there is no sessionID and I need to build those sessions. I have the following dataset: UserId INT, EventId INT, DateCreated DATETIME, BlockId INT Assume the following data: ...

Mysql Fulltext help

I am using this to search my table: if ($querystring!=''){$query_cont .= " AND MATCH (headline) AGAINST ('$querystring')"; } Thing is, in the 'headline' field I have a value of say 'BMW'. Then when I enter BMW in the search field, that is "$querystring = 'BMW'", no results are found. I have set the index of the 'headline' field to ...

execution time of a stored procedure

What is the age old method of testing execution time of stored procedures on informix 11.5. I am thinking of doing something like this from a unix prompt: $ time (echo 'execute procedure foo(1)' | dbaccess ...) Any other ideas? ...

Homework: no subquery in getting a value indirectly

I'm having a hard time creating a query for smth that sounds like this: what is the name and color of the items that cost more than grey box detergent(2 attributes: color:grey, type:detergent). NOTE: I'm NOT allowed to user subqueries or use the price as a constant. using subqueries I managed to get this: SELECT name, color FROM i...

What ways are there to simplify the install of a php app for linux and hopefully windows as well?

I have a php application ( http://github.com/tchalvak/ninjawars ), essentially a php-based webgame that I run at http://ninjawars.net . I frequently configure and install the app for myself for localhost development, and it's a somewhat trial-and-error hacked-up process. Now that I've open sourced the app, I've got some users wishing t...

Php connection to database

I am trying to connect to a database using a login form. Currently there is one user in the database but when pressing submit the page just appears to refresh and is not redirected to the home page as it should. Here is my code: <html> <head><title>Login</title></head> <body> <?php ob_start(); include('connect.php'); $handle = mysql_...

SQL check when creating a table

Is it possible to have a CHECK under the form: CREATE TABLE abc (no INTEGER, det INTEGER NOT NULL, quo INTEGER CHECK (quo < AVG(st.quo)), qoh INTEGER CHECK (qoh >= 0)); So basically every time new values are entered to check the average of quo of another (existing) table in the database and if and only if it's lower than the average...

What's an easy way to populate a database through an sql query from a single entry?

We're looking to populate a number of tables for testing. The data can all be the same except for a timestamp column. Other columns in the row contain complicated data, like objects in xml format and other messy stuff, so we don't want to have to remake it. What would be an easy way to expand a single entry to thousands, by incrementing ...

How to change 'ft_min_word_len' in WAMPSERVER ?

I can't figure out where it is located. I only find a 'my.ini' file which doesnt have a 'mysqld' section in it... Do I have to upload my website to an ACTUAL server before attempting this? Thanks ...

Why are foreign keys more used in theory than in practice?

When you study relational theory foreign keys are, of course, mandatory. But in practice, in every place I worked, table products and joins are always done by specifying the keys explicitly in the query, instead of relying on foreign keys in the DBMS. This way, you could of course join two tables by fields that are not meant to be for...

Zend Db avoiding sql injections

Hi, I have the following code: public function checkLoginDetails($email, $password) { $select = $this->select (); $select->where ( "password=?", md5($password) ); $select->where ( "email=?", $email ); return $this->fetchRow($select); } email and password come directly from the user. Do I need to filter email with, say, mysql_real...

SQL Server EnumParameters Method on StoredProcedure object in SQL Server 2008 SQL-DMO

Hello all you wonderfully helpful people, What is the alternative to EnumParameters in SQL Server 2008? This MSDN article mentions that this method is going away, so what should be used instead? http://msdn.microsoft.com/en-us/library/ms133474%28SQL.90%29.aspx Here is the error we receive when attempting to use this method: Micros...

Best practice for a SQL Archiving Stored Procedure

I have a very large database (~100Gb) primarily consisting of two tables I want to reduce in size (both of which have approx. 50 million records). I have an archive DB set up on the same server with these two tables, using the same schema. I'm trying to determine the best conceptual way of going about removing the rows from the live db a...