sql

Oracle : select maximum value from different columns of the same row

The whole question is pretty much in the title. For each row of the table I'd like to select the maximum of a subset of columns. For example, from this table name m1 m2 m3 m4 A 1 2 3 4 B 6 3 4 5 C 1 5 2 1 the result would be name max A 4 B 6 C 5 The query must be compatible oracle 8i. Thanks. ...

How do I pivot this in T-SQL?

How do I get this: entityid name stringvalue ----------- -------------------- -------------------- 1 ShortDescription Coal 1 LongDescription BlackCoal 1 ShortDescription Gold 1 LongDescription WhiteGold 1 ShortDescription Steel 1 LongDes...

C# - Password Database

So I want to make a program that allows you to store and search for user names/passwords for online sites there signed up to. I know C# has some database options but I don't know much about it. I also heard that it can read/write excel files. Whats do you think is best for storing the data? ALSO do databases need to be stored online o...

PIVOT not performing as expected.

Sorry for an unclear question previously; hopefully I can start again... I have this data: entityid name stringvalue ----------- -------------------- -------------------- 1 ShortDescription Coal 1 LongDescription BlackCoal 1 ShortDescription Gold 1 LongDescription ...

querying larg text file containing JSON objects.

Hi, I have few Gigabytes text file in format: {"user_ip":"x.x.x.x", "action_type":"xxx", "action_data":{"some_key":"some_value"...},...} each entry is one line. First I would like to easily find entries for given ip. This part is easy because I can use grep for example. However even for this I would like to find better solution because...

SQL Server - access to sys.views for a highly privileged user

I have case where I want a database user to have db_owner privileges with regard to one databases on the server, but be able to see absolutely nothing of other databases on the server, including, for example, the sys.databases view. I have tried denying select on this view at the master database level, but this prevents the user even fr...

How do I use a concatenation of 2 columns in a SQL DB in ASP.NET properly?

I'm using LinqToSql like this with a CheckBoxList in ASP.NET: var teachers = from x in dc.teachers select x; cbl.DataSource = teachers; cbl.DataTextField = "name"; cbl.DataValueField = "teacherID"; cbl.DataBind(); I want to display both "firstname" and "name" in the DataTextField however. I found this solution but I'm using ...

Oracle global temporary tables - maximum number of records?

Hello, Is there a limit on how many records can go to a global temporary table, before it affects performance, and does it affect performance? I am talking here about millions of records that might be inserted to a global temporary table. ...

Tool for sql refactoring?

Is there a refactoring tool available for SQL (TSQL in particular). Is there any tool that can do automatic simplification of SQL? I have a set of views where only the top two are used, and I'd like to refactor this into only two views, hence 10+ queries into two queries. ...

I need to run a stored procedure on multiple records

I need to run a stored procedure on a bunch of records. The code I have now iterates through the record stored in a temp table. The stored procedure returns a table of records. I was wondering what I can do to avoid the iteration if anything. set @counter = 1 set @empnum = null set @lname = null set @fname = null --...

Generate Java class with JPA annotations from an SQL script

Anyone know a tool for generating Java class with JPA annotations from an SQL script? Batch process would be a plus since I have a large amount of sql objects. ...

Using SMO to script table as select

SSMS allows you to right-click a table and "Script Table as"->"Select to". I thought that almost everything in SSMS was done through the SMO scripting engine, but I can't seem to find a way to do this through SMO short of looping through columns and generating the script myself. Is my Google-Fu weak, or are people just not using SMO for...

Looking for a good book on SQL

Was wondering if any one could recommend any and all books for learning more about SQL and DB concepts? I found this one while browsing SO, but was wondering if anyone had other or more up to date recommendations? ...

Debugging stored procedures, without using SSMS 2008 Debugger, or the Visual Studio debugger (output variable values?)

I have a SQL Server 2005 database with some Stored Procedures (SP) that I would like to debug...essentially I would just like to check variable values at certain points throughout the SP execution. I have SSMS 2008, but when I try to use the debugger, I get an error that it can't debug SQL Server 2005 databases. And I can't use the Vis...

T-SQL - Left Outer Joins - Filters in the where clause versus the on clause.

I am trying to compare two tables to find rows in each table that is not in the other. Table 1 has a groupby column to create 2 sets of data within table one. groupby number ----------- ----------- 1 1 1 2 2 1 2 2 2 4 Table 2 has only one column. number ----------- 1 3 4 So Tabl...

help for a query

Hi, i've a problem for a table update. follow table structure: Table1 tableid ... ... productID_1 productID_2 productID_3 Table2 productID Total I've to totalize each product in table2. For example: SELECT COUNT(*) as tot, ProductID_1 FROM Table1 GROUP Table1 then the UPDATE table2 SET total =..??? (how can...

How can I 'transpose' my data using SQL and remove duplicates at the same time?

I have the following data structure in my database: LastName FirstName CourseName John Day Pricing John Day Marketing John Day Finance Lisa Smith Marketing Lisa Smith Finance etc... The data shows employess within a business and which courses they have s...

SQL hidden techniques?

Possible Duplicate: Hidden Features of SQL Server What are those pro/subtle techniques that SQL provides and not many know about which also cut code and improve performance? eg: I have just learned how to use CASE statements inside aggregate functions and it totally changed my approach on things. Are there others? UPDATE: ...

How to compare sqlite TIMESTAMP values

I have an Sqlite database in which I want to select rows of which the value in a TIMESTAMP column is before a certain date. I would think this to be simple but I can't get it done. I have tried this: SELECT * FROM logged_event WHERE logged_event.CREATED_AT < '2010-05-28 16:20:55' and various variations on it, like with the date functio...

How can I use SQL to select duplicate records, along with counts of related items?

I know the title of this question is a bit confusing, so bear with me. :) I have a (MySQL) database with a Person record. A Person also has a slug field. Unfortunately, slug fields are not unique. There are a number of duplicate records, i.e., the records have different IDs but the same first name, last name, and slug. A Person may also...