sql

Saving "Tags" - Quickest Way

I want to save tags related to a discussion post. The same as the 'tags' that Stack Overflow uses. What is the best way to do this? I was thinking of saving them in the 'discussion' table as a single comma separated string, but I'm not sure if this is the 'fastest' way assuming there will be lots and lots of rows in the discussion tab...

why do you have {} around variables in a sql statement?

why do you use {} around variables in following sql statement? SELECT FROM users WHERE username = '{$_POST['user']}' ...

Can you make a call to a C++ Application from MS SQL Server?

Is it possible to make a call/notification to a C++ application from Microsoft SQL Server? To give a broader understanding of what I'm trying to achieve: our database is being updated with new information; Whenever a new piece of information is received, we'd like to push this to the C++ application so that its dashboard reflects up-to...

Help me good SQL Ebooks

Hello everyone, I have basic knowledge about SQL. But I still have difficulty when write SQL for the complex queries. Please help me some ebooks to improve my skill to write SQL, and the way to write a good SQL for performance. The book should have example database to practice. Thanks. ...

Inbox-System Checkboxes To Select Messages

We currently are implementing an inbox system into our website and want a user to be able to checkmark multiple inbox messages and click a Delete link to mass-delete them. Each inbox message has it's own ID in the database. What we need help with is getting the checkbox system working. We don't know where to start with it; whether we h...

Get parent property in child select in Powershell?

I want to include a parent level property in a child result set in Powershell and I can't figure out how to do it. An example of what I want to do would be to include the ServerName as the first column of a pipe to get the DatabaseName and a list of Database properties of all the databases on the server similar to: [System.Reflection.A...

Update selected records - noob

Hi, Sorry this is a bit of a noob question. I have the following select statement. I would like to update the values of ContactAssociate from 'Bob' to 'Jane'. Is it possible to do this? SELECT TOP (1500) ContactID, ContactNotes, ContactAssociate, ContactAppointment FROM tb_Contact WHERE (ContactAssociate = 'Bob') AND (ContactAppointmen...

UNIQUE - way to have unique rows in table ?

I have problem with unique rows in db table, now it is posible to do that: id | Name | LastName | City ------------------------------------- 1 | John | Moore | London 2 | John | Moore | London when i use UNIQUE attribute in all columns i have errors inserting second Moore even it is different Name :/ how use UNIQUE (...

TSQL Pseudo Random text generator

I am doing some performance testing on a SQL sproc and just want to bang out a quick data generator for testing. I am after a simple way to generate a pseudo random (true random not needed in this case) varchar field. Ideas I have so far is having a character definition of valid characters that can be used and then build the string fro...

sql server get only updated record

Hi, I am using sql server 2000. I need to get only updated records from remote server and need to insert that record in my local server on daily basis. But that table did not have created date or modified date field. ...

What is the SQL to create a table where its PK is also a FK?

Say I have: create table Post( PostID int not null constraint PK_Post primary key clustered, Title nvarchar(200) not null ) on [primary] create table PostDetail( PostID int not null constraint PK_PostDetail primary key clustered, Text nvarchar(max) null ) on [primary] How do I make PostDetail.PostID an FK referencing Post.Pos...

C#/SQL Database listener help needed

I have a requirement to monitor the Database rows continuously to check for the Changes(updates). If there are some changes or updates from the other sources the Event should be fired on my application (I am using a WCF). Is there any way to listen the database row continuously for the changes? I may be having more number of events to...

SQL ASP.NET [Sql Command error]

SqlCommand cmd = new SqlCommand("FlowClientHardQ 0, 10, 1, 1, 364, Null", conn); works with no error SqlCommand cmd = new SqlCommand("FlowClientHardQ @ID_User, @ID_ListGroupParIzm, 1, 1, @CIzmer, Null", conn); cmd.Parameters.AddWithValue("@ID_User", user); cmd.Parameters.AddWithValue("@ID_ListGroupParIzm", ID_L...

Single Query to delete and display duplicate records.

Hi, One of the question asked in an interview was, One table has 100 records. 50 of them are duplicates. Is it possible with a single query to delete the duplicate records from the table as well as select and display the remaining 50 records. Is this possible in a single SQL query? Thanks SNA ...

How to find "related items" in PHP

Hi, we often see 'related items'. For instance in blogs we have related posts, in books we have related books, etc. My question is how do we compile those relevency? If it's just tag, I often see related items that does not have the same tag. For instance, when search for 'pink', a related item could have a 'purple' tag. Anyone has any ...

How to limit an SQL result set to not too common items

Problem: I have a list of names and addresses. Some names (persons) have the same address (street, zip code, town) like others. I want to select all those names with addresses with no more than three occurrences and from the rest the first three names each of a bunch pointing to the same address. Example: Albert | Adr1 Berta | Adr1 Cesa...

How to escape special characters in SQL strings from Delphi?

Hi, How to escape the special characters when executing an SQL query, when it is executed from Delphi using TADOQuery or TADOCommand etc.. For example the "scope operator". Query looks like this. GRANT CONTROL ON SCHEMA :: dbo TO supervisor Thanks & Regards, Pavan. ...

MySql takes a long time optimizing a join-less query

We have a simple query that looks like: SELECT a,b,c,d FROM table WHERE a=1 and b IN ('aaa', 'bbb', 'ccc', ...) No joins at all, 5000 contsant values in the IN clause. Now, this query takes 1-20 seconds to run on a very strong (16 core) server. The table has an index on (a,b), and we also tried reversing the index to (b,a). The serve...

MYSQL - select first 4 records for each category in a table

I have a table INVENTORY that has among other columns CATEGORY and UPDATED. Sorting the table by these columns is easy: SELECT * FROM INVENTORY ORDER BY CATEGORY ASC, UPDATED ASC What I want is to get a result set that contains only the first 4 rows from each category. Any idea how to get it done? ...

How can I represent a single row from result set as multiple rows ?

Given for example a currency rates table with these columns (used 3 here, but in my situation there are about 30): date | eur | usd | gbp 2010-01-28 | X | Y | Z How do I convert it to this one (using row with the latest date): currency | rate eur | X usd | Y gbp | Z I've come up with a query like this: SEL...