sql

Reporting Services 2005 configuration

I need help with configuring Reporting Services. I have the ReportServer and Report Manager running successfully under a virtual website and under their own virtual directories (Reports and ReportServer) on port 80. I then tried to set up another virtual website running on port 1001 with the same virtual directory names I am able to ...

Rollback in Ironpython using System.Data.SqlClient

I am unable to rollback using the following code snippet and need help: import clr import sys clr.AddReference('System.Data') from System.Data.SqlClient import SqlConnection, SqlParameter, SqlTransaction conn_string = "****" connection = SqlConnection(conn_string) connection.Open() createuser = connection.CreateCommand() createuser.Comm...

LINQ / SQL Performace problem with a very long list

In our database we have a table with more then 100000 entries but most of the time we only need a part of it. We do this with a very simple query. items.AddRange(from i in this where i.ResultID == resultID && i.AgentID == parentAgentID orderby i.ChangeDate descending select i); After this Query we get a List with up to 500...

Sybase Development IDE

Is there a Toad type application for Sybase? I can't seem to find a single one! I've tried using VS 2008 but can't see the sproc source. ...

How to write a constraint concerning a max number of rows in postgresql?

Hi, I think this is a pretty common problem. I've got a table user(id INT ...) and a table photo(id BIGINT, owner INT). owner is a reference on user(id). I'd like to add a constraint to the table photo that would prevent more than let's say 10 photos to enter the database for each users. What's the best way of writing this? Thx! ...

Why are SQL server inserts so slow?

I'm trying to insert rows of in memory data into a table on sql express 2005. It is running what seems to me very slowly - about 5 seconds per 1000 rows inserted. I am just using a basic "INSERT INTO" command. The slowness does not depend on the table data - it is still slow with a table with one int column and no index. It is nothing to...

Column 'dbo.mdSpaceSales.wkid' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

I am getting the above error for the query below : SELECT a.stid, a.pfid, pf.pfname, a.mdid, mm.mdDescription, a.categoryid, a.SummedSpace, a.AvgSpace, mm.size_sqft as MML_size, a.TotalRev, a.TotalProfit, a.wkCount, a.Lastwkinst FROM (SELECT wkid, stid, mdid, pfid, categoryid, sum([space]) as SummedSpac...

select maximum two mark out of three

I have table contain the mark for three exam for one subject each mark in different column how to select best two mark from the three column ? ...

Getting a list of columns to show next to the column they are related to

I've got a table setup like so: [ReferredID], [Name] 1, Irwin 2, Marc 1, Johnny 5, Jackie 2, Perry 1, Reuben I'm trying to get a query that will produce this: [ReferredID], [List] [1], [Irwin, Johnny, Reuben] [2], [Marc, Perry] [5], [Jackie] Can you help me find the right query to produce these results or something near? ...

TSQL SELECT then UPDATE in one transaction, then return SELECT

I am really having trouble with a query in my ColdFusion application (backended to MS SQL 2008). I keep getting DB deadlock errors on this transaction: <code> <cftransaction> <cfquery name="selectQuery"> SELECT TOP 20 item_id, field2, field3 FROM Table1 WHERE subject_id = #subject_ID# AND lock_field IS NULL AND ...

Insert xml data into sql tables

I have an xml document with the following format: <response username="123" customerName="CustomerName" siteName="SiteName" customerID="123" Period="2009"> <topics> <topic name="MyTopic"> <department name="MyDepartment" parent="OriginalDepartment"> <questionHead result="Go" group="Group A" surveyID="1" questionID="2" ...

SQL for cases with 2 or more hits

Hi, I have this table that has a lot of book related fields including keywords. Book_ids are primary keys. Let's say I have a book with six keywords describing it, now how do I search all the other books that have two or more same keywords? What I have now is roughly this: select book_id from book_fields where keyword in ( select ke...

Grouping dates by month in an sql server query (stored procedure)

Im having a bit of a mental block on this one. I got booking system for hotel rooms and it contains a table as so BookingRoomLink BookingId (FK) RoomId (FK) Start_Date End_Date I'd like to query the data to extract occupancy levels for each month. I could do this manually (ie for the past month do something like this). SELECT Book...

Mysql: Optimizing finding super node in nested set tree

I have hierarchical data in a nested set model (table:projects): My table (projects): id, lft, rgt 1, 1, 6 2, 2, 3 3, 4, 5 4, 7, 10 5, 8, 9 6, 11, 12 7, 13, 14 ... Pretty printed: 1 2 3 4 5 6 7 To find the nearest super node of node 3 (knowing its lft value), i can do explain SELECT projects.* FROM projects WHERE 4 BETW...

How do I copy a SQL Server database

Hello, I was wondering what my options are for copying a SQL Server database. If this is a repeat I'll delete my question but I couldn't find an answer when using the search. This is what I already tried: -Write the database to a sql script. When I do this I always seem to run into a problem where I have to manually adjust stuff. ...

SQL Syntax question

What does the following statement mean? Is it an equivalent for TOP? select +10 as ContentID ...

Tips or tricks for translating sql joins from literal language to SQL syntax?

I often know exactly what I want, and know how tables are related in order to get it, but I have a real hard time translating that literal language knowledge to SQL syntax when it comes to joins. Do you have any tips or tricks you can share that have worked for you in the past? This is a basic, but poor example: "I have Categories, whi...

How to write a good PHP database insert using an associative array

In PHP, I want to insert into a database using data contained in a associative array of field/value pairs. Example: $_fields = array('field1'=>'value1','field2'=>'value2','field3'=>'value3'); The resulting SQL insert should look as follows: INSERT INTO table (field1,field2,field3) VALUES ('value1','value2','value3'); I have come u...

Multiple conditionals within sql query

I want to pull out the records that have a date that is LIKE today's date. I have this query $query = "select * from calendar_items WHERE expiredate LIKE '$todays_date %' or upcoming_event_featured_date like '$todays_date %' ORDER BY expiredate ASC"; Now I have 3 more upcoming_event_featured_date's: upcoming_event_featured...

Oracle Hierarchical Query

Using Oracle 10g. I have two tables: User Parent ------------- 1 (null) 2 1 3 1 4 3 Permission User_ID ------------------- A 1 B 3 The values in the permissions table get inherited down to the children. I would like to write a single query that could return me something like this: User P...