sql

Free SQL formatting tool?

Hey, is there a good free tool out there that can also format complex queries? Thanks :-) ...

Scheduling Procedures in sql server 2008 am i doing it the right way or there are issues?

EDIT : Problem with the email I get mailbox unavailable exception! DBEmail.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Xml.Serialization; using System.IO; using System.Xml; using System.Text; using System.Net; using System.Net.Mail; using System.Xml.Linq; public partial ...

SQL Server 2008 - ssas user permission

I'm new to ssas and i'm fighting with users permissions... I have a cube with a region dimension i.e region A and region B. I created a role to filter dimension data so that members of that role have only access to region A. I put user A in this role. Now, when I test this configuration, if I select the role A in the security context,...

Insert binary file in SQLite database with Python

I trying to write a simple Python script that inserts .odt documents into an SQLite database. Here what I have so far, but it doesn't seem to work: f=open('Loremipsum.odt', 'rb') k=f.read() f.close() cursor.execute="INSERT INTO notes (note) VALUES ('%s')" %(sqlite.Binary(k)) cursor.close() conn.close() I don't get any error messages, ...

Storing Allowed Websites Per User in Postgres

Hi all, I have a User table in my Postgres database. In my application, the User can have various allowed websites. My question is: which is more disk space efficent, having a many-to-many relationship between a user and a url or storing the array in JSON in a column in the User table. Essintially, how much space does postgres use to st...

How do I add breakpoints to a stored SQL Procedure for debugging?

I am trying to debug a SQL procedure, and am using the following query to do so. USE [database] GO DECLARE @return_value int EXEC @return_value = [dbo].[Populate] @ssId = 201 SELECT 'Return Value' = @return_value GO The problem is, the procedure I am testing, (Populate) doesn't seem to stop at any of the breakpoints I ...

Pound signs (£) disappearing from ASP.NET strings

Hi all, I'm usually a LAMP developer, but some .NET work has arrived on my plate and I'm a bit stumped. If I run the following code: <% poundsign = "£" %> <% Response.Write poundsign %> <% Response.Write "£" %> … nothing is displayed. However, outside of the <% %> tags (ie in the HTML) £ displays correctly. I have no trouble displa...

Remove duplicate rows in MySQL

I have a table with the following fields: id (Unique) url (Unique) title company site_id Now, I need to remove rows having same title, company and site_id. One way to do it will be using the following SQL along with a script (PHP): SELECT title, site_id, location, id, count( * ) FROM jobs GROUP BY site_id, company, title, location ...

Visual Studio 2010 built-in fake/test data generator for SQL Server

I few months back I attended a Microsoft EnergizeIT seminar where they were showing some of the capabilities of their latest development products. One of the things they had shown that really caught my eye was a built in mock data generator tool to generate mass amounts of fake data from a few seed lists. I don't remember the name of the...

mysql: how do i make a copy of the entire database?

how do i make an exact duplicate copy of a database in mysql? create database test1 from test ??????? if this is not possible, how do i copy a table from one database into another"? ...

does this lock the database?

insert into test.qvalues select * from qcvalues.qvalues; i would like to knwo if the above line locks the database QCVALUES ...

Type Comparisons in SQL

I've got the following bit of code as part of a SQL Query: INSERT INTO [Database] SELECT DISTINCT @ssId FROM [Document_Map] WHERE (LabelId IN (SELECT Tokens FROM StringSplitter(@sortValue, '|', 1)) The code works fine as long as @SortValue is an integer, (LabelId is an int as well) or integers separat...

SQLCacheDependency with 100000 Records.

We are using SQLCache Dependency in our asp.net application. We are storing like 100000 records in the cache is that good practice or we need to find alternate solution because sometimes our server CPU banging 100% due to it and we have to reset application pools. Any help will be greatly appreciated. ...

Compare Every Record from Two Tables

Assuming I have two SQL tables consisting of a single column, i.e. Table 1 Table 2 a1 a2 b1 b2 c1 c2 Is there a succinct SQL command to compare each record in one table against each record in the other? (and return true if any record from table 1 matches any recor...

Entry-level programming job

I'm new to stack-overflow but it seem like you people are a bright bunch and have the knowledge that I lack as an almost college grad. I have one semester left and am looking forward to working as a programmer. I started out as a QBasic programmer at the wee age of 9 and made a couple of games that were really buggy but it kept me ente...

Cannot delete or update a parent row - JPA with Hibernate

I have a database in which all of the tables have been generated by Java JPA/Hibernate code. I need to update several tables in my database in a fashion similar to this, UPDATE Department SET id=100000 WHERE id=0; Unfortunately this results in the error ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constr...

MySQL JOIN query help: return only one row from the right-most table for every row in the left-most table

I have two tables. I want to join them in a way that only one record in the right table is returned for each record in the left most table. I've included an example below. I'd like to avoid subqueries and temporary tables as the actual data is about 4M rows. I also don't care which record in the rightmost table is matched, as long as one...

SQL schema Table compare

I'm looking for an app that will compare the layout of 2 SQL tables. When developing in a DEV environment, I need a tool that will make the production tables exactly like the DEV tables (the layout). ...

Deleting a detached database SQL 2008

I detached a database, and when i try to re-attach it i am getting error: CREATE FILE encountered operating system error 5(failed to retrieve text for this error. Reason: 15105) while attempting to open or create the physical file 'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\RoadMap.mdf'. (Microsoft SQL Serve...

Slow query, can I speed it up?

I'm retrieving images stored as blobs in the database using a python script running on the same server. SELECT * FROM imagedb_production.imagedb IMAGE LEFT JOIN dccms_production.tblmedia MEDIA ON IMAGE.name = MEDIA.name LEFT JOIN dccms_production.tblmultimedia CAP ON MEDIA.contentItemID = CAP.contentItemID LIMIT 5000,100...