sql

disaggregate summarised table in SQL Server 2008

Hi I've received data from an external source, which is in a summarised format. I need a way to disaggregate this to fit into a system I am using. To illustrate, suppose the data I received looks like this: receivedTable: Age Gender Count 40 M 3 41 M 2 I want this is a disaggregated format like t...

How to avoid using duplicate savepoint names in nested transactions in nested stored procs?

I have a pattern that I almost always follow, where if I need to wrap up an operation in a transaction, I do this: BEGIN TRANSACTION SAVE TRANSACTION TX -- Stuff IF @error <> 0 ROLLBACK TRANSACTION TX COMMIT TRANSACTION That's served me well enough in the past, but after years of using this pattern (and copy-pasting the above c...

Does an insert made in a transaction is visible by SELECT before transaction is commited

I need a confirmation. Client 1 insert rows in a table inside a transaction. Client 2 request this table with a SELECT. If on this client isolation level is set to READ COMMITTED, can you confirm that the SELECT won't returns the rows that aren't yet committed by Client 1. Thanks ...

ASP.NET Create User Wizard - Customisation help

Hi folks, I have used the asp membership feature to add user management to my web app. I have modified the default tables to include a couple more fields. On the create user wizard I have turned wizard step one into a customizable template and have added in the controls for the 2 fields. Do I know just modify the stored procedure used...

Date type in oracle does not include time values

I have a PHP application using an Oracle XE database. Whenever I add a date the hours minutes, and seconds seem to get left out. Is there some special format, or type I should use to be able to store this? I have tried using to_date, and specifying the format I am using. Many thanks for any suggestions from this confused MySql dvelope...

insert a BLOB via a sql script ?

Hi, I have an H2 database (http://www.h2database.com) and I'd like to insert a file into a BLOB field via a plain simple sql script (to populate a test database for instance). I know how to do that via the code but I cannot find how to do the sql script itself. I tried to pass the path , i.e. INSERT INTO mytable (id,name,file) VALUE...

Linq sql Attach, Update Check set to Never, but still Concurrency conflicts

In the dbml designer I've set Update Check to Never on all properties. But i still get an exception when doing Attach: "An attempt has been made to Attach or Add an entity that is not new, perhaps having been loaded from another DataContext. This is not supported." This approach seems to have worked for others on here, but there must be ...

selecting data from table based on date .

i have database table like this +-------+--------------+----------+ | id | ip | date | +-------+--------------+----------+ | 505 |192.168.100.1 |2010-04-03| | 252 |192.168.100.5 |2010-03-03| | 426 |192.168.100.6 |2010-03-03| | 201 |192.168.100.7 |2010-04-03| | 211 |192.168.100.10|2010-04-03| +-------+--------...

SQL - Conditionally evaluate WHERE clauses

I need to get a WHERE clause to only evaluate certain statements. something like: WHERE field_a = field_b AND (CASE WHEN <PARAM>type</PARAM> = 5 THEN {field_c = 1 OR field_c = 2} WHEN <PARAM>type</PARAM> = 6 THEN {field_c = 3 OR field_c = 4} ELSE field_c = <PARAM>type</PARAM> so that when the Param type = 5...

T/SQL Efficiency and Order of Execution

Hi All, In regards to the order of execution of statements in SQL, is there any difference between the following performance wise? SELECT * FROM Persons WHERE UserType = 'Manager' AND LastName IN ('Hansen','Pettersen') And: SELECT * FROM Persons WHERE LastName IN ('Hansen','Pettersen') AND UserType = 'Manager' If there is any diff...

SQL Where clause conditional assignment based on another parameter

I need to generate a report where the user can choose All Issues, Open Issues, or Closed issues in a radio button. In my view I have a isClosed bit column. If I didn't have the All Issues radio box I'd just do: SELECT * FROM MyView WHERE isClosed = @ViewClosedRecords However I need to remove the isClosed = @ViewClosedRecords condition...

Oracle(10) SQL: calculating final sum depending on two field

First the disclaimer: I never learnt any programming in school, and just have to deal with various SQL problems (too). So now I've got two tables, TABLE1: ACCNO BAL1 BAL2 11111 20 10 And TABLE2 (which has the ACCNO key, of course) related rows to '11111': DATENUM AMT 1 -5 2 -10 3 8 4 -23 5 100 6 ...

Comma separated list of values as different rows, not as fields for one row, for an SQL INSERT

I want to make many inserts in a single SQL statement, pretty much like INSERT INTO xxx SELECT field FROM zzz But with values I don't have in a table, and are just a list of literals. Normal way would be executing one SQL query for each value, but if there exists a standard SQL statement, or MySQL-specific, it would be great. ...

Using Parameter Values In SQL Statement

I am trying to write a database script (SQL Server 2008) which will copy information from database tables on one server to corresponding tables in another database on a different server. I have read that the correct way to do this is to use a sql statement in a format similar to the following: INSERT INTO <linked_server>.<database>.<ow...

Pulling parameters from a datagridview C#.NET

I have what is undoubtedly a simple question, but I can't seem to find that answer anywhere. I am writing a C# Windows form application that contains a datagridview that I'm using to run a SQL UPDATE statement out to the database with a dataadapter. I am using a parameterized query and need to populate the parameters with columns from th...

Are there any differences between SQL Server and MySQL when it comes to preventing SQL injection?

I am used to developing in PHP/MySQL and have no experience developing with SQL Server. I've skimmed over the PHP MSSQL documentation and it looks similar to MySQLi in some of the methods I read about. For example, with MySQL I utilize the function mysql_real_excape_string(). Is there a similar function with PHP/SQL Server? What step...

finding a relationship accross many tables

Hi I've inherited a development with nearly 800 tables. I need to produce reports that span multiple tables. I'm usong the likes of SQL Dependency Tracker to help me find the required tables, but even this is painful. Do you know of a app that I can say [start table] [end table] now find me all the tables inbetween? Any ideas? Thank...

ASP, sorting database with conditions using multiple columns...

First of all, I'm still working in classic ASP (vbScript) with an MS Access Database. And, yes I know its archaic, but I'm still hopeful I can do this! So now to my problem: Take the following table as an example: PROJECTS ContactName StartDate EndDate Complete Mitch 2009-02-13 2011-04-23 No Eric 2006-10-01 2008-11-15...

Ado.net Fill method not throwing error on running a Stored Procedure that does not exist.

I am using a combination of the Enterprise library and the original Fill method of ADO. This is because I need to open and close the command connection myself as I am capture the event Info Message Here is my code so far // Set Up Command SqlDatabase db = new SqlDatabase(ConfigurationManager.ConnectionStrings[Connecti...

SQL Full-Text Indexing Issue

UPDATE: I have figured out a way using a form of dynamic sql to fix this problem, thanks anyway for any help. Hi, there is something that I need to accomplish with the use of Full-Text Indexing. This is it: The fact of the matter is when I run a query (with a stored procedure) that looks like (with a parameter (@name) that was obvious...