sql

SQL scramble database varchar fields

Hi, I have to create a test database for some external developers to use. We have created a copy and rather than manually filling it with junk data i want to scramble the text fields. Are there any easy ways of doing this? Im using sql server 2005 Sp ...

back up a database

Hi everyone, I need to back up a big database everydays. Should I code it myself in PHP or is there a good script out there ? ...

SQL FOREIGN KEY USAGE ? what does it really do ? and when it was needed ?

ok im makeing a simple database for my example, there is users data and the user company's data . CREATE TABLE `users` ( `UID` INT(25) NOT NULL AUTO_INCREMENT , `username` VARCHAR(60) NOT NULL , `password` VARCHAR(100) NOT NULL , `ownername` VARCHAR(150) NOT NULL , `userstatus` TINYINT(1) NOT NULL , `userregistertime` DATETI...

Hibernate... how does one do database/SQL queries?

I (think I) understand that Hibernate offers me access to a relational database essentially as if I had a class(es) that matched whatever view(s) I define of some tables. How do I get the results of a specific query to be accessible via a class? In particular, can I issue a complex SQL query, and process multiple results? Do I lose an...

LINQ: How to join nested Lists in an ObjectCollection

Hi, is it possible to define a LINQ statement for the following problems WITHOUT using a foreach loop? public class GroupObject { public String name; public List<String> letters; public void test() { List<GroupObject> myGroups = new List<GroupObject> { new GroupObject { name="test1", ...

SQLite -> finding two closest points to two different points

Hi everybody. So I have 2 tables : route(#id) step(#id,route_id,lat,lng,sequence_order) And 2 GPS coordinates : M1(lat1, lng1) M2(lat2, lng2). So I want to find all the routes which have at least one step closer than 1.0 mile from each of the 2 GPS coordinates with a ascending sequence order. So if I find Route#25 which has a step ...

Multiple Alias names for a table

Can we have multiple alias names for a single table? ...

Is Alias and CTE are same?

Hi All, Is select id from (select * from employee ) as t is same as ;with temp as (select * from employee) select id from temp ????? Both will return same result.But regarding performance oriented. ...

NHibernate show-sql - why is the SQL shown invalid?

Hi all I love the feature in NHibernate that shows the generated SQL. But when I pasted it into SQL Server Management Studio, I realised it's not actually valid! Here's an example: SELECT person0_.PersonId as PersonId1_0_, person0_.Title as Title1_0_, person0_.FirstName as FirstName1_0_, person0_.MiddleNames as MiddleNa4_1_0_, person0...

Why does Oracle SQL mysteriously resolve ambiguity in one joins and does not in others

Hello. I'm an Oracle 10g user. I had to write some SQL queries, and spotted a mysterious (as I see it) behaviour. Let's pretend we have a table, which is able to join itself in some kind of simple two-level tree structure. The next query gives me "ambiguity error", which is expected: select title from table1 left join table1 on c...

Usage of index on several columns

If I built a btree index on columns (one, two, three, four, five) will it be used for a query with where block: (1) ... WHERE one = 1 AND two = 2 AND three = 3 AND four = 4 -- no five or (2) ... WHERE two = 2 AND one = 1 -- wrong sequence, no five or (3) ... WHERE one = 1 AND three = 3 AND two = 2 AND five = 5 AND four = 4 -- wron...

Can i monitor performance of particular table in sql server 2008 profiler

I want to monitor all the DML commands that run on a particular table of my database in sql server profiler. Im using sql server 2008 R2 ...

Oracle using variable in where like

I'm trying to run SQL in a PL/SQL procedure. If I were to say: SELECT * FROM myTable WHERE FNAME like 'Joe%' AND dept = 'xyz'; this runs instantly. if I try putting 'Joe' in a variable it takes forever to run, about 3 minutes. Here is some syntax I found for using like with variables. PROCEDURE myProcedure(firstName IN VARCHAR, ...

beautifying multiple XSD files

I have about 50 XSD files that are really badly formatted. I know if I open them all in Visual Studio, I can beautify them one by one. My question is: Is there a way to command line beautify them or some way I can do this in bulk? ...

Rails Postgres functional indexes

How I should enter my multicolum indexes which contain functions into schema.rb ? for example this DOESN'T work: add_index "temporary_events", ["templateinfoid", "campaign", "date(gw_out_time)", "messagetype"], :name => "temporary_events_campaign_tinfoid_date_messagetype" rake db:test:load rake aborted! PGError: ERROR: ...

Bad Code: Why is this dangerous?

Possible Duplicate: Can I protect against SQL Injection by escaping single-quote and surrounding user input with single-quotes? String badInput = rawInput.replace("'","''"); ResultSet rs = statement.executeQuery("SELECT * FROM records WHERE col1 = '"+badInput+"'"; Is there any way to do a "Bobby Tables"-like attack...

Finding and Ordering Latitude and Longitude in SQL

I have a SQL database where I store longitude and latitude from an iPhone application. I need to query all the records starting from a given location to the other far most location. For example, I have longitude x and latitude y. I want all the records first whose longitude matches x the most closely and whose latitude matches y the mo...

Oracle Join View - which rowid is used

Hi, CREATE VIEW EVENT_LOCATION ("EVENT_ID", "STREET", "TOWN") AS SELECT A.EVENT_ID, A.STREET, A.TOWN FROM TBLEVENTLOCATION A JOIN TBLEVENTS B ON A.EVENT_ID = B.EVENT_ID WHERE B.REGION = 'South'; if I run SELECT ROWID, STREET, TOWN FROM EVENT_LOCATION then which ROWID should I get back? Reason I'm asking is: In the data...

SQL Server 2005 and SQL Server 2008 Coexisting in Windows 7 machine

Some SQL Server 2005 and 2008 questions. 1) Can they coexist on the same Windows 7 machine without issues? 2) Can you attach and run 2005 databases to SQL Server 2008 without compatibility issues or is this a no go? 3) Does SQL Server 2005 even work on Windows 7? ...

How are uniqueidentifiers calculated?

I was curious as to how SQL Server calculates uniqueidentifiers. I understand that uniqueidentifiers, are GUIDs but are these calculated based on system time? Or are they calculated based on the name of job/script that has called the NEWID() function. I found this but i found this reference to be unclear. ...