sql

Inserting an auto incrementing Primary Key into another table (to join with later)

I'm pretty new to MySQL, and I hope i'm getting things right. I've set up a database with 3 tables with columns as below (Primary keys are PK): Users table uid (PK) username Directories table uid path project DirInfo table infoID (PK) size dateofcheck exists pathID When I insert NULL values to Directories.pathID, I get a new...

display column alias from other tbl

I have 2 tables tbl1 and tbl2 tbl1 has userid col1 col2 col3 (multiple records per user) EDIT tbl2 has userid col4 col5 col6 (Single record per user) On my original post I had col3 listed here as well which was accident. tbl2 is used to store custom column names for each user. now I need to know how do I display this custom column n...

Get the records of last month in SQL server

I want to get the records of last month based on my db table [member] field "date_created". What's the sql to do this? For clarification, last month - 1/8/2009 to 31/8/2009 If today is 3/1/2010, I'll need to get the records of 1/12/2009 to 31/12/2009. ...

unique count of the columns ?

i want to get a unique count of the of multiple columns containing the similar or different data...i am using sql server 2005...for one column i am able to take the unique count... but to take a count of multiple columns at a time, what's the query ? ...

Algorithm for Auto-Appending a Unique ID to Duplicate Titles

I have a user that enters a piece of data into my database and titles it "Widget Title". If he calls another item "Widget Title", and another, and another, when he sees them in his widget list I'd like to show them like such: Some Item Widget Title Some Other Item Widget Title 2 Widget Title 3 Yet Another Item Widget Title 4 Where ea...

FOR XML AUTO in stored procedure

will FOR XML AUTO queries in stored procedures and using ExecuteXmlReader to retreive data to set business objects cause any performance hit? ...

How to give string value in the query?

Using VB6 and Access 2003 Query Select Temp.* into NewTable from Temp Table Name storing in Stroutput as a string. Tried Query. Select Temp.* into ‘ ” & Stroutput & “ ’ from Temp From the above query am getting error in ‘ ” & Stroutput & “ ’. When i give temptable instead of ‘ ” & Stroutput & “ ’ is working. How to give a strin...

Access sometimes jumps to existing record on save new record - Access2k FE/SQL2005 BE

Hi, this is my first question on SO, am really posting this out of desperation after searching around a lot for an answer and trying a few different things with no success. I have an Access database where I have recently migrated the tables to SQL 2005, Access continues to function to the users as a front-end providing forms, reports, ...

Select Rows with Maximum Column Value group by Another Column

This should be a simple question, but I can't get it to work :( How to select rows that have the maximum column value,as group by another column? For example, I have the following table definition: ID Del_Index docgroupviewid The issue now is that I want to group by results by docgroupviewid first, and then choose one row from eac...

Date Column was created

Hi, Do you know if there is a way to get the creation date for a SQL Server 2005 table column? I tried the sp_columns [tablename] to get some table information but no luck. Thank you. ...

Help with setting up a Database

My site is going to have many products available, but they'll be categorised into completely different sites (domains). My question is, am I better off lumping all products into one database and using an ID to distinguish between the sites, or should I set up a table and /or DB per site? Here are my thoughts SEPARATE DATABASES Easie...

Optimize for speed a simple stored procedure

Hello: In SQL 2008 I've this easy-but-bad-write sp that works: ALTER PROCEDURE [dbo].[paActualizaCapacidadesDeZonas] AS BEGIN SET NOCOUNT ON; DECLARE @IdArticulo AS INT DECLARE @ZonaAct AS INT DECLARE @Suma AS INT UPDATE CapacidadesZonas SET Ocupado=0 DECLARE csrSumas CURSOR FOR SELECT AT.IdArticulo,...

Can you tell SQL Server not to return specific rows?

We have a database where contacts are only soft-deleted, i.e. we set a bit named deleted to true. The API handles this, but sometimes you need to run queries directly against the database and it's easy to forget that bit, and export contacts that are actually deleted. It's not a big problem, because I'm used to the system, but if I'm on ...

How are nested set models traversed in MySQL?

I'm reading this article and on the part with the query: SELECT node.name FROM nested_category AS node, nested_category AS parent WHERE node.lft BETWEEN parent.lft AND parent.rgt AND parent.name = 'ELECTRONICS' ORDER BY node.lft; I'm wondering how is it travered? What happens step by step? I'm confused, please help. ...

Sql - format phone number

HI , i have table in the db with phone number column the numbers look like this 123456789 i want to format tham to 123-456-789 thanks!!! ...

Stored procedure: return multiple columns instead of multiple recordsets?

This is probably a really simple question, but I don't write stored procedures often and I'm a bit mystified... After doing various stuff, the concluding bit of the SP ends by returning counts or sums from several different tables. The obvious approach is: select SUM(ThisCol) as ThisResult from... select SUM(ThatCol) as ThatResult from...

How Do I create a log using performance monitor in SQL?

A company I deal with have their own server, and a couple of sites using SQL server 2005 on it. They are getting random, intermitten freezes and its pointing to SQL Server so the company who they got the server from said to "create a log using performance monitor in SQL" I have RD Access... Is this a simple setting I just need to put ...

Using Memcache for storing connection objects

Is it advisable to store SQL Connection objects in memcache? ...

Grouping with operands question

I have a table: mysql> desc kursy_bid; +-----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+-------------+------+-----+---------+-------+ | datetime | datetime | NO | PRI | NULL | | | currency | varchar(6) | NO | PRI | NULL | | | va...

Top tools for c#/sql developer.

I love resharper it makes refactoring other peoples code also most fun. www.jetbrains.com/resharper And ghost doc is another great tool. http://submain.com/GhostDoc I would love to use redgates sql prompt but my company wont pay for it ? so free tools are the best :) My question is what other great tool are in the c#/sql dev toolbar? ...