sql

(SQL) How do I query for a list of items that share attributes while listing the rows independently?

Hi All, Having a bit of a "special" moment here. Basically I have a DB table for listing files and their attributes (size, creation date, etc). Being a self-proclaimed (borderline delusional) SQL-whiz, you can imagine my surprise when I failed to figure out a quality manner by which to individually list only files whose [INSERT ATTRIB...

Count based on condition in SQL Server

Does anyone know how can I do a count in SQL Server based on condition. Example: How can I do a column count for records with name 'system', and total caseid records in the table?? Customer table userid caseid name 1 100 alan 1 101 alan 1 102 amy 1 103 system 1 ...

How many queries in one webpage?

How many queries in one webpage is good performance? If that page is home page that is viewed many times. and how about.... $sql1 = mysql_query("SELECT * FROM a", $db1); while($row = mysql_fetch_assoc($sql1)){ $sql2 = mysql_query("SELECT * FROM b WHERE aid='a'", $db2); $a = mysql_fetch_assoc($sql2); } is it good? acctually I can ...

ASP.NET - SQL Process Design Connect to Multiple DBs

Scenario Web server running an ASP.NET site that's connected to a sql server instance for all the web related DB needs (products, pricing, users, etc.)... The companies accounting, inventory control(FIFO, etc.) and whatnot are mainly done on another system which uses a different SQL server...much more complex, for obvious reasons. Wha...

Why Non null values in Sparse columns takes extra space in SQL Server 2008

Hello Guys, May I know why Sparse columns which are having non null values takes 4Bytes of extra space..I am finding out why it is taking 4 bytes of extra space.. Please help me out? ...

How to select records grouped by the hour of the day including hours that have no records

I have a table in an Oracle database that contains actions performed by users in one of our systems. It's used for statistical analysis and I need to display the number of actions performed for a given date, grouped by hour of the day. I have a query that does that fine, however, it does not display the hours of the day that contain no ...

Is there a more ideal way to query data from another database using SQL Server 2005?

I have a stored procedure which gets data from another database on the same server. I will not be hard-coding which database to use, instead this will be configurable. Is this possible without dynamic sql? The best solution I could come up with so far is to first run a stored procedure which uses dynamic sql to generate a bunch of view...

SQL query with week days

Hi I would like to know what is the best way of creating a report that will be grouped by the last 7 days - but not every day i have data. for example: 08/01/10 | 0 08/02/10 | 5 08/03/10 | 6 08/04/10 | 10 08/05/10 | 0 08/06/10 | 11 08/07/10 | 1 is the only option is to create a dummy table with those days and join them altogether? th...

Identify row matches across multiple columns

I have been given a table that is populated by '1' and '0' based on the yes/no answers to a survey. I have been asked to identify all totally distinct answers, i.e. People who answered 'Yes' to questions 1, 17, 23, 234 and 238. There are many columns (500+) and thus many answer permutations. Any ideas? ...

need an algorithm to create nested categories in c#

Hi , I have a table structure like below : categoryID bigint , primary key , not null categoryName nvarchar(100) parentID bigint, not null where as categoryID and parentID has an one-to-many relation to each other and I want to create a nested categories with unlimited depth out of this table in my program. I have a solution but i...

Difference between jobs and maintenance plan in sql server

What is the difference between jobs and maintenance plan in sql server? I am confused about where I should use job and where maintenance plan. ...

How to replace leading null values with the first non-null value in a row?

I'll try to avoid describing the background here. I now have a query result (not a table) which contains rows like this: ID SP1 SP2 SP3 SP4 SP5 SP6 SP7 SP8 1 null null 2500 1400 700 null null null There may be leading and/or trailing null values around a section of non-null v...

Multiple-step OLE DB operation generated errors

Dim NorthWindOledbConnection As String = "Provider=SQLOLEDB;DataSOurce=SARAN-PC\SQLEXPRESS;Integrated Security=ssp1;InitialCatalog=Sara" Dim rs As New ADODB.Recordset() rs.Open("select * from SecUserPassword", NorthWindOledbConnection, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockBatchOptimistic) i tried to run this ab...

One-To-Many reflexive association INSERT data

Hi, I have a table with One-To-Many reflexive association. I need insert the first value disabling temporary the constraint. Any idea how to do it? I use MS SQL 2008, thanks guys for your support! CREATE TABLE dbo.CmsCategories ( CategoryId int NOT NULL IDENTITY (0,1) -- Seed = 0 and Increment= 1 ...

SQL TEST BOOKS DOWNLOAD LINKS

Can any one provide the SQL Text books links to download? (text books) PDF/document to download, not link to view ...

SQLBase and NHibernate?

Looking for a way to use SQLBase (by Unify, formerly Gupta) with NHibernate. I don't think there is a specific SQLBase provider, but I guess there would be generic providers to connect and use the most common SQL features... Any help would be appreciated. ...

Update all parent id's in a SQL mptt table

Hi, consider a SQL table, which stores hierarchical data using MPTT (Modified Preorder Tree Traversal) method. CREATE TABLE node ( id SERIAL NOT NULL, -- primary key -- Nested mptt tree model. lft INT NOT NULL, rgt INT NOT NULL, -- Some legacy a...

How does this not make varchar2 inefficient?

Suppose I have a table with a column name varchar(20), and I store a row with name = "abcdef". INSERT INTO tab(id, name) values(12, 'abcdef'); How is the memory allocation for name done in this case? There are two ways I can think of: a) 20 bytes is allocated but only 6 used. In this case varchar2 does not have any significant adva...

Connecting to an Oracle database from Windows Azure?

We are facing some annoying issues while trying to remotely connect to an Oracle database from a Windows Azure worker instance. The problem has been already discussed on the MSDN, but at this point, we are still stuck. Does anyone has succeeded in establishing a connection toward an Oracle database from a .NET app hosted in Windows Azur...

MySQL: Getting connected (simillar) data with lef/right fields

In MySQL Im having two tables: PRODUCTS (id, Name) SEEALSO (id, prodLeft, prodRight) SEEALSO defines which PRODUCTS are related together and are represented as binded fileds "prodLeft"-"prodRight". For Example: PRODUCTS: 1 Desk 2 Table 3 Chair 4 Doors 5 Tree 6 Flower SEEALSO 1 1 2 2 2 3 3 3 4 4 5 6 From that we can see bin...