sql

How to represent and insert into an ordered list in SQL?

I want to represent the list "hi", "hello", "goodbye", "good day", "howdy" (with that order), in a SQL table: pk | i | val ------------ 1 | 0 | hi 0 | 2 | hello 2 | 3 | goodbye 3 | 4 | good day 5 | 6 | howdy 'pk' is the primary key column. Disregard its values. 'i' is the "index" that defines that order of the values in the 'val...

How do I accurately handle a batch separator for SQL from C#

For Data Explorer I would like to add support for a Batch separator. So for example if users type in: select 'GO' go select 1 as go Go select 100 I would like to return the three result sets. Its clear that I need some sort of parser here, my hope is that this is a solved problem and I can just plug it in. (writing a full T-S...

Storing i18n data in a database using XML

Hello, I may have to store some i18n-ed data in my database using XML if I don't fight back. That's not my choice, but it's in the specifications I have to follow. We would have, by example, something like following in a 'Country' column: <lang='fr'>Etats-Unis</lang> <lang='en'>United States</lang> This would apply to many columns in...

Ordering Wordpress posts by most recently commented on

What's the query to list wordpress posts by most recent, with posts most recently commented on going to the top of the order? (Standard "message board" style) This post looked promising: http://stackoverflow.com/questions/698438/ordering-wordpress-posts-by-most-recent-comment But the query is clearly wrong. Can anyone help? ...

Get sum() result in one query in Mysql

Hello, I have a table id name state num 1 x in 10 2 x out 1 3 x in 5 4 x out 2 5 y ... 6 y ... The expected result is to sum the num for 'in' and 'out' in one query and then calculate the difference, like name numin numout diff x 15 3 12 y .... Thanks ...

Merge two rows in SQL

Assuming I have a table containing the following information: FK | Field1 | Field2 ===================== 3 | ABC | *NULL* 3 | *NULL* | DEF is there a way I can perform a select on the table to get the following FK | Field1 | Field2 ===================== 3 | ABC | DEF Thanks Edit: Fix field2 name for clarity ...

SQL Server combining 2 rows into 1 from the same table

Hi, I have a table with an JobID (PK), EmployeeID (FK), StartDate, EndDate containing data such as: 1, 10, '01-Jan-2010 08:00:00', '01-Jan-2010 08:30:00' 2, 10, '01-Jan-2010 08:50:00', '01-Jan-2010 09:05:00' 3, 10, '02-Feb-2010 10:00:00', '02-Feb-2010 10:30:00' I want to return a record for each EndDate for a Job and then the same emp...

how to select distinct rows for a column

Hi, all. I have a table x that's like the one bellow: id | name | observed_value | 1 | a | 100 | 2 | b | 200 | 3 | b | 300 | 4 | a | 150 | 5 | c | 300 | I want to make a query so that in the result set I have exactly one record for one name: (1, a, 100) (...

Error: No mapping exists from object type....

Here is the code for my simple parsing application. I am getting an error that states 'No mapping exists from type System.Text.RegularExpressions.Match to a known managed provider native type'. This started to occur when I switched from using Split('_') to RegEx.Match for defining RNumberE, RNumberD, etc. Any guidance is appreciated. us...

how to show partial key in uml er diagram

in chen's notation partial keys (discriminator) were shown as dashed lines, how are they shown in uml er (entity-relationship) diagram? ...

insert SQL dummy column

HI there.. this is a bit hard to explain so i will show code of the update equivalent .. declare @dummy as int; UPDATE pages SET @dummy = 0 ,field ='asdsa' ... etc because i am writing a code generator it gets messy trying to determine if a comma is needed or not.. i am having this problem with inserts now.. ive trie...

How can I get reports for last 24h in SQL?

I need to get all reports made in last 24h, table has CreatedDate column, so I need to check in database that report was created in last 24h. I know I can use getdate() to get current date, but how can I minus 24h from that attrbiute and then compare that date with CretedDate? ...

joining table of oracle

Hi friends i am having problem in joining two tables in oracle my two tables are shown bellow table1 looks like id Name Jan 7001 Deven 22 7002 Clause 55 7004 Monish 11 7010 Dipesh 55 7070 Dipika 100 table2 looks like id Name Feb 7001 Deven 12 7002 Clause 15 7003 ...

is TransactionScope usable for sql operations, is it doing the same thing as Sqltransaction ?

can I do something like this: using (var scope = new TransactionScope()) { using (var conn = new SqlConnection(Cs)) { using (var cmd = conn.CreateCommand()) { cmd.CommandType = CommandType.StoredProcedure; ....

how to get Next month date from today date (i.e) exactely one month expires from today date

i have maintained two datas into my table 1 column 2 column PaidDate validitydate in padidate ill give insert todaydate. but in validity date i may either insert validity for 1 week/1 month. I have used validity=DATEADD(Day,7,@paiddate) to insert validity for 1 week. but how to gtet the validity for 1 month from todays date ...

Database abstraction/adapters for ruby

What are the database abstractions/adapters you are using in Ruby? I am mainly interested in data oriented features, not in those with object mapping (like active record or data mapper). I am currently using Sequel. Are there any other options? I am mostly interested in: simple, clean and non-ambiguous API data selection (obviously)...

Why there is "GO" after USE db" in T-SQL examples?

Hi, Looking at the msdn, there was an example on "GO" command. Why there is: USE somedb GO ... ... It it neccesary to select db in different batch? Thanks for explanation! ...

import data from another table with same id

Hi, i have 2 table User (id, name, surname,cod) UserNew (uid, uname, usurname, ucod) The first table has data the second no. I have to copy the data of the User table in the UserNew table. I've tried with a insert query but uid (primary key) value changes. How can i do to mantaince the same values? thanks ...

Parser output sqlplus for get errors using C#

Hi all, I need parser the output of sqlplus, for get list of errors of compilation of sql files, using C# Any sample, please ?? Thanks in advanced. Greetings ...

Real time SQL database updates between multiple VB.NET clients

Hi, I hope somebody can help me out on this question. I'm using a SQL database and I'm writing a VB.NET client application. This application is used on multiple computers at the same time. If one of the clients makes an update to the database I would like to have the other clients to be aware of the update. Has ony one already done th...