sql

normalize mysql tutorial please...

Is there a good guide for normalizing a mysql db? I have only knowledge about phpmyadmin... Thanks ...

Manage errors among Dev Teams

We are going through some very interesting debates as to how we should manage errors/issues in our IT department. I would really like to hear what others say about how they manage application/feed, etc generated errors. We are being pushed to put everything into BPEL (Business Process Execution Language) so that the non devs can see w...

how would you normalize / optimize this mysql database?

I have a classifieds website, with alot of categories. When the user posts an 'ad' on the website, there are some basic info (name, city, price, headline, text etc...) that has to be filled in. And also, depending on what 'category' the user choses to insert the ad into, some more fields will have to be filled in, for example: if the ca...

What's the difference between "::" and "sys" schemas?

As far as I know, BOL exmaple on fn_trace_getinfo used to use :: instead of sys schema in the example like following From SELECT * FROM ::fn_trace_getinfo(default) To SELECT * FROM sys.fn_trace_getinfo(default) Are there any differences between those two? And what does :: mean? ...

Formatting text with PHP

Is there a way I can format a list so I can insert it via SQL? My current list format is test:test and I want to be able to format it so it will insert into my database. INSERT INTO `test` (`user`, `file`) VALUES ('test', 'test'), ('test2', 'test2'), ('[email protected]', 'test3'); Is this possible by any chance? <? if($_POST['oldlist'...

What does varchar(-1) mean?

What is the meaning of varchar(-1) in SQL Server 2008? Is it an alternative for varchar(max)? ...

Trunc(sysdate) in SQL Server

What is the equivalent of: TRUNC(SYSDATE) ...in SQL Server 2005? ...

Can anyone advice on a simple way to create SQL tables on the fly, using a CSV file upload in a .NET Web App?

Hi, I have checked a few answers but was unable to find specific details on how we can create a SQL table using custom metadata (or Columns from a CSV file) which is uploaded by a user through a CSV file. A feature available with www.dabbledb.com, like creating online database for custom information. It will be a web based .NET applicati...

How can I do this in SQL in a Single Statement?

Hi, I have the following MySQL table: +---------+------------+------+--------+------+---------+------------+-------+---------+----------+------------+------------+ | Version | Yr_Varient | FY | Period | CoA | Company | Item | Mvt | Ptnr_Co | Investee | GC | LC | +---------+------------+------+--------+------...

how to erase sql quries from ActiveRecord::Base.logger

Hi All, I'm developing an application using Ruby on Rails. I would like to erase old queries in the ActiveRecord::Base.logger object every time when i call a new action, essentially where ENV = production. the goal is not to erase all queries like using config.log_level :info. i need only last queries to build a file whith those quiri...

SQL ERROR: Operand should contain 1 column(s)

I have this query and I get error "Operand should contain 1 column(s)", whats wrong in my query? SELECT * FROM contact AS b WHERE b.id IN ( SELECT * FROM contact AS e WHERE e.firstname LIKE ? OR e.lastname LIKE ? OR e.email LIKE ? OR e.phone LIKE ? OR e.company LIKE ? OR e.profession LIKE ? O...

LEFT OUTER JOIN (gives extra rows) problem

I have two tables which I want to join together using a left outer join. However, even though my left table contains only unique values, the right table satisfies the CONDITION more than once and as such, adds extra rows to the resultset. Code to replicate problem: declare @tb1 table (c1 int) declare @tb2 table (c2 int) INSERT INTO ...

SQL Server Stored Procedure Fails due to use of XML/ ANSI_NULLS, QUOTED_IDENTIFIER options

I have a stored procedure which takes an XML parameter and inserts the data into multiple tables. If I run the stored procedure into a database using a SSMS query window, everything works fine. However, we have a custom installation program that is used to deploy stored procedures to databases, and when this is used, execution of the sp ...

is it good to use check constraints for business rules

Currently we are using check constraints for business rules implementation, but I want to know should we implement business rules in sql or Business logic(c# code) layer. I have searched on the net and finds that check constraints are good to use. please let me know if somebody knows more int detailed abt it. One more thing is that data ...

ANSI SQL Manual

Can anyone recommend a good ANSI SQL reference manual? I don't necessary mean a tutorial but a proper reference document to lookup when you need either a basic or more in-depth explanation or example. Currently I am using W3Schools SQL Tutorial and SQL Tutorial which are ok, but I don't find them "deep" enough. Of course, each major ...

Delete rows from multiple tables using a single query (SQL Express 2005) with a WHERE condition

This is the query I'm using: DELETE TB1.*, TB2.* FROM TB1 INNER JOIN TB2 ON TB1.PersonID = TB2.PersonID WHERE (TB1.PersonID)='2' It's working fine in MS Access but getting error (Incorrect syntax near ','.) in SQL Server Express 2005. How to solve it? Please help. ...

Is there any reason not to join Foreign Key to Foreign Key?

I have the following tables: Financial: PK_FinancialID FK_SchoolID School: PK_SchoolID Class: PK_ClassID FK_SchoolID ClassName Both Class and Financial have Foreign Key relationships to School. I want to make a query that would show all classes that are related to Financial rows that meet certain criteria. Initially I think...

How to return multiple values using case statement in oracle.

Hi, I want to return multiple values from a query in oracle. For ex: select count(*) from tablename a where asofdate='10-nov-2009' and a.FILENAME in (case when 1 = 1 then (select distinct filename from tablename where asofdate='10-nov-2009' and isin is null) else null end); I am getting error: ora 01427 single ro...

Need help with normalizing my database

I am woundering whether someone has time to normalize my database? I dont know if it needs normalization, but I want to do everything perfectly, and I dont know if it is already good or not. I have used phpMyAdmin to create my database... Background: Im making a classifieds website. One category of ads is 'cars'. So far, I have create...

Roles vs Schema

I want to give different level of access on tables to different users based on their department. Should I use Schema or Roles for this purpose. Any Insights! ...