sql

TSQL Shred XML - Is this right or is there a better way (newbie @ shredding XML)

Ok, I'm a C# ASP.NET dev following orders: The orders are to take a given dataset, shred the XML and return columns. I've argued that it's easier to do the shredding on the ASP.NET side where we already have access to things like deserializers, etc, and the entire complex of known types, but no, the boss says "shred it on the server, ret...

TSQL Shred XML - Working with namespaces [ANSWERED]

Here's a link to my previous question on this same block of code with a working shred example Ok, I'm a C# ASP.NET dev following orders: The orders are to take a given dataset, shred the XML and return columns. I've argued that it's easier to do the shredding on the ASP.NET side where we already have access to things like deserializers,...

Combining two-part SQL query into one query

Hello, I have a SQL query that I'm currently solving by doing two queries. I am wondering if there is a way to do it in a single query that makes it more efficient. Consider two tables: Transaction_Entries table and Transactions, each one defined below: Transactions - id - reference_number (varchar) Transaction_Entries - id - acco...

Business Hours of Operation in SQL/C#

I am having a massive brain fart on this one for some reason. I have a table with "Hours of Operation" for a business. The table has: - Day (Monday = 1, Sunday = 7) - Start Time - End Time I'm trying to figure out how to write the cleanest code (using Linq to SQL) that will check if hours are overlapping on submit of new hours and modif...

LINQ to SQL SOUNDEX - possible?

Hello, I have done a little bit of research on this and looked through a few articles both here on StackOverflow as well as some blog posts, but haven't found an exact answer. I also read that it is possible to do it using the 4.0 framework, but have yet to find any supporting evidence. So my question, is it possible to perform SOUNDEX...

Encryption from c# application

SITUATION: I need to make encryption happen between my remote database and my c# application. I don't know what I'm doing (never done any encryption before) and all the stuff I found on the web was for asp.net and dealt with the web.config file. SOME RELEVANT DATA: My connection string contains password info for SQL server authenticatio...

Updating records with their subordinates via CTE or subquery

Let's say I have a table with the following columns: Employees Table employeeID int employeeName varchar(50) managerID int totalOrganization int managerID is referential to employeeID. totalOrganization is currently 0 for all records. I'd like to update totalOrganization on each row to the total number of employees under them. So ...

How to convert row data into columns in SQL

Hi, I have looked into pivot but I think it requires an aggregate function which I do not need (I think). The result of my query is this Name Property Name PropertyValue ---------- ---------- ---------- lorem Work Phone 000.111.2020 ipsum Email tes...

From Now() to Current_timestamp in Postgresql

In mysql I am able to do this: SELECT * FROM table WHERE auth_user.lastactivity > NOW() - 100 now in postgresql I am using this query: SELECT * FROM table WHERE auth_user.lastactivity > CURRENT_TIMESTAMP - 100 but I get this error: operator does not exist: timestamp with time zone - integer How can I resolve ? ...

How to realize this in Transact SQL ( SQL Server 2008 )

I just want an update trigger like this postgresql version... It seems to me there is no NEW. and OLD. in MSSQL? CREATE OR REPLACE FUNCTION "public"."ts_create" () RETURNS trigger AS DECLARE BEGIN NEW.ctime := now(); RETURN NEW; END; Googled already, but nothing to be found unfortunately... Ideas? Update: Sth, like this? CREATE ...

SQL Server 2005 and SELECT and UPDATE locked

I want to perform a update then select the result. I don't want anything to be able to update the row I am updating until after the select has occurred. How would I do this? My goal is to increment a value of a row and return that incremented value. I have thus far found that I end up with an issue where update (to increment) followed b...

Equivalent of mysql_insert_id() for Postgresql ?

Possible Duplicate: mysql_insert_id alternative for postgresql Is there a Postgresql equivalent of mysql_insert_id() to get the ID generated in the last query ?? ...

how/resources to compile a procedural language into [sql]

I am looking into the possibility/feasibility/resources for building a cross compiler which takes a procedural or Object Oriented language like C, or Java and compiling it into SQL. I understand that the advantage of SQL code is performing set operations which is fundamentally different from procedural languages which generally process 1...

Why is this postgresql query so slow?

I'm no database expert, but I have enough knowledge to get myself into trouble, as is the case here. This query SELECT DISTINCT p.* FROM points p, areas a, contacts c WHERE ( p.latitude > 43.6511659465 AND p.latitude < 43.6711659465 AND p.longitude > -79.4677941889 AND p.longitude < -79.4477941889) ...

Prevent HTML character codes from being rendered in textarea

Is it possible to display HTML character codes stored in a text field in SQL to a textarea without rendering them as their appropriate character? i wasnt & to show up as &amp; (the way it's stored in the table). Or is their a way I should be storing the HTML so I won't need to worry about this? (site is using PHP) ...

Non-Linear Database Retrieval

I'm building an article system, and each article will have one more Tags associated with it (similar to the Tags on this site). The tables are set up something like this: Article_Table Article_ID | Title | Author_ID | Content | Date_Posted | IP ... Tag_Table Tag_ID | Name ... Tag_Intersect_Table Tag_ID | Article_ID Is it p...

Why does PostgreSQL have to be different (scheme does not exist)?

I'm not used to working with PostgreSQL, but am using Zend_Db_Select to create my queries. What does the error below mean? SQL error: ERROR: schema "il" does not exist In statement: SELECT il.count(*) AS "count" FROM "image_lite" AS "il" INNER JOIN "exif_parse" AS "ex" ON il.image_id = ex.image_id WHERE (ex.cam_make = 'apple') ...

How to compare int list to SQL subquery

Hello, Is there a way to compare a list of numbers to a SQL subquery something like WHERE 9,10,11 = (SELECT tableID FROM ....) EDIT: I guess my question isn't clear but I'm sorry, I really don't know how else to say this. I'm expecting a list of IDS back from the subquery like 1,2,3 or at least that's what I'd like the result to look...

How to convert full outer join query to O-R query?

I'm converting relational database into object-relational in Oracle. I have a query that uses full outer join in the old one. Is it possible to write the same query for O-R database without explicitly using full outer join? For normal inner join it simple, I just use dot notation together with ref/deref. I'm interested in this in gen...

how can i loop through all of the columns of the OracleDataReader

I have the following code and i want to loop through all the fields in the result of this query and populate the dictionary called field. Given a datareader is this possible? OracleCommand command = connection.CreateCommand(); string sql = "Select * from MYTABLE where ID = " + id; command.CommandText...