sql

MySQL - How can I get names of all students that were taught by teacher with name John?

How can I get all students names that were taught by the teacher with name John? student id name student_has_teacher teacher_id student_id teacher id name ...

which sql supports vista

i have windows vista in my laptop.. i have installed visual studio 2008..i need sql server... i tried sqlexpress 2005.. it shows the compatibility issues.. i proceeded further, finally it shows error 1603.. i provided full rights to the directory where installed.. help me.. thanks a lot in advance ...

updating similar fields in sql server

Is there a way to search for fields that contain similar values in a sql db? For example I have a table of over a million records where one column contains url values and is associated with a country column. Previously I tried to match urls that are equal where it contained a null value for the country as was able to update it using the...

Simple MS SQL count question

I have this SQL DECLARE @url varchar(100) SET @url = 'http://mysite.com/%' SELECT [UserSessionSequenceID] ,[SiteID] ,[Referer] ,[Timestamp] ,ROW_NUMBER() over (PARTITION BY [Referer] ORDER BY referer DESC) AS sort FROM [tblSequence] WHERE [Referer] IS NOT NULL AND [Referer] NOT LIKE @url AND siteID = 15 Want to c...

How to show row numbers in PostgreSQL query?

I'd like to show the observation number for each record returned by a PostgreSQL query. I think in 8.4 windowing functions can perform this capability. Edit: I think I just found the answer, but since this hasn't been asked before, I'll keep the question open. I also welcome non-windowing function possibilities. Edit 2: So a little t...

In Django, correctly making a queryset with multiple categories, multiple tags and search?

I have a list of data. This data model has many-to-many fields to both a categories model and a keywords model. The data model itself has a name and description. The data can have multiple categories and keywords. On the front end, the user can select a number of categories to filter down the data or do a search... So the data shown sho...

How can I update a newly added column in the same batch statement

In SQL Server 2008, I would like to add a column to a table and update it right after, but only if they column hasn't been created before. I do NOT want to run the update if the column has been created before. IF NOT EXISTS (SELECT * FROM [INFORMATION_SCHEMA].[COLUMNS] WHERE [TABLE_NAME] = 'SETTINGS' AND [COL...

Cannot open database "DBName" requested by the login. The login failed. Login failed for user 'MachineName\User'.

I created a web application but when trying to connect the DB I am getting this error Cannot open database "DBName" requested by the login. The login failed. Login failed for user 'MachineName\User'. I also tried adding that this user manually but it give error that this login already exist with different username..but it not shows in ...

Problem in WHERE clause

So I have a query. It works if I comment out the part checking for the exclusion. WHERE H.BatchId = 3 AND H.IsExcluded != 1 IsExcluded is a bit field that accepts NULL values. All the values I'm selecting from are NULL, so that SHOULD be right. What am I doing wrong? It's returning no values the way it is, but if I comment out just ...

Adding extra field to sql query

I have a query i've written for a private message system but i would like to add an extar field in the query but not sure how to do it. At the moment it gets the username of the sender but not the recipient but it does however get both ids of sender/recipient. How do i add an extra field in my query to get the username of the recpient?...

How to separate this comma delim column to new table

Hello experienced SQL'rs... I've got a little issue (SQLServer 2005) that I've run into with a legacy table (I'm honestly not trying to cover my embarrassment here - it is an old table :-)). Basically, for reasons best known to the original coder, one of the columns is being used to record changes of state to the object referred to in t...

Best way to go about storing/accessing PDF Files

Hey guys, Just a quick question (maybe not) I'm looking to add to my website a way for a customer to login and once logged in they are able to select their invoices which i will upload to my server. My question is what is the best way to go about storing the files and accessing them. i've done some googling and haven't been able to f...

Create a DATABASE using as a Name from a Variable

I would like create a database using value from a variable. Here my script but it does not work. Any ideas? -- Set Data Base name DECLARE @DataBaseName char(64); SET @DataBaseName = 'DbCmsWebsiteTest'; -- Create Data Base CREATE DATABASE @DataBaseName; GO ...

How can I filter this data from my database?

I have a table with a name and type field. The type field contain the musical taste of the person in this way: "Rock; Pop; Metal; Dance" (varchar) I need to generate an excel list with this persons grouped by music taste. For example: One list with everybody in Rock; Metal; Dance Another with everybody in Rock; Metal; Trance Another...

How to separate this field into two columns

Hello again fellow sql'rs, I've got a seamingly simple problem to solve that normally would be fairly easy. I've got a field that contains a DateTime portion, as well as a trailing text portion. I now need to split this field into two discrete fields - DateTime and Varchar. Now for the little gotcha. The data has been saved with two dif...

Unique Index Error when creating non-unique index - SQL Server

I trying to and a non-unique index to a table table in SQL Server 2005. I am getting the following error when I try to create it. Msg 1505, Level 16, State 1, Line 1 The CREATE UNIQUE INDEX statement terminated because a duplicate key was found for the object name 'dbo.oe_pick_ticket' and the index name 'idx_pick_ticket_popup_wmms...

Visual Studio 2008 - Default Encoding style with .SQL files

Tools used: Visual Studio 2008 Team Foundation Server or Visual Source Safe Backstory: We add our SQL files to our source control. We do this by adding them to the solution with the .sql extension and checking them in. By default these files are saved as unicode. What that means is that user A can save foo.sql and user B can get late...

[Hibernate] How to group results by intervals?

Hello all, I have a table containing events with a "speed" property. In order to see the statistical distribution of this property, I'd like to group the results by intervals, let's say: [0-49.99km/h] 3 objects [50-100km/h] 13 objects [100-150km/h] 50 objects etc This would let me see that most objects are in a certain interval. Ob...

optimizing a view for hierarchical data

I currently have a query that contains a self-join to query all the direct and indirect managers of an employee from a table that stores company organization info using the nested sets model. In this SQL notation, numbers preceded by a colon (e.g. :1) are variables: select parent.empid, parent.depth from RelationshipMgr as node join Re...

Code vs Database - Sequence of Steps, Call Database or Check Session Object?

I have several web sequential pages which will modify a record and its child records in the database, called a "project". Such a project is currently passed between pages using its database ID in the URL parameters. A project has some information specific to itself, and also consists of one or more Tasks, which each have information sp...