sql

Scripting your database first versus building the database via SQL Server Management Studio and then generating the script

I had a (friendly but heated) argument with my lead developer the other day because our project has TSQL Scripts that I code directly into SQL files which I then run against the database. I find that when I do this, it's easy to work out the schema in advance without fiddly pointing and clicking and then there's no opportunity to forget ...

AWStats SQL Tool?

Hi, does anyone ever heard of a tool/script/etc. which allows to import an AWStats created logfile ( e.g. as text or xml ) into a SQL-DB? I just want to figure out if i really have to write a parser-script myself... thanks. ...

Optimize MySQL query to avoid "Using where; Using temporary; Using filesort"

Hey all, I built a custom forum for my site using MySQL. The listing page is essentially a table with the following columns: Topic, Last Updated, and # Replies. The DB table has the following columns: id name body date topic_id email A topic has the topic_id of "0", and replies have the topic_id of their parent topic. SELECT SQL_CA...

How to get the latest 2 items per category in one select (with mysql)

My data looks like the following: id|category|insertdate|title.... -------------------------------- 1|1|123|test 1 2|1|124|test 2 3|1|125|test 3 4|2|102|test 4 5|2|103|test 5 6|2|104|test 6 What I try to accomplish is get the latest 2 entries per category (as in order by insertdate DESC), so the result should be: id|.... ---- 3|......

OVER clause in Oracle

What is the meaning of the OVER clause in Oracle? ...

C# SQL Server Extra Slash Added to String When Connecting To Named Instance

Hi, I am trying to connect to a named instance of sql server from c#. I saw a similar article on this site, but it didn't seem to have the issue I am having. I am reading values from a table into a string. When I put the named instance into a string, I get an extra slash, and it doesn't connect. So if the database field has "myserve...

SQL 2005 Trying to regain space from database

I have a SQL 2005 database with one large table. I have ran a DELETE to prune some items from the table and I want to free the space back to the OS. I have tried the following commands DBCC SHRINKDATABASE (MyDB, TRUNCATEONLY); DBCC SHRINKFILE (MyTable, TRUNCATEONLY); and I have also rebuilt the clustered index with the following com...

How can you cancel a SQL Server execution process programmatically

Let's say you have execute the following (long running) process from your code: int processID = DB.Execute(SQL); //some long running sql statement Is there a way to programatically call SQL Server to cancel the process if it is taking too long (kind of like hitting the "Stop" button in QueryAnalyzer)? //cancel the process if it is ta...

How do I change a column's Format to Percent using a SQL in VBA?

I have a query in VBA that Adds a few columns to a table. How can I change the format of the PercentSuccess column to Percent using SQL in VBA? Here is the code I'm using to add the columns. strSql5 = " Alter Table analyzedCopy3 " & _ "Add Column PercentSuccess Number, Success Number, prem_addr1 TEXT(50) " DoCmd.SetWarnings Fals...

Best Practice : Import CSV to MYSQL Database using PHP 5.x

Howdy Folks, what is the best solution to import large amounts of records into an MySQL or Oracle Database. I Think there are two ways : Insert every record with an persistent connection Create on BIG SQL-Statement and query the Database Iam not sure wich is performing better ? Is there any Best Practice Solutions for this kind of o...

SQL 2008 Compression

Hello, I am an intern and was asked to do some research on SQL 2008 data compression. We want to store several parts of outlook emails in a table. The problem is that we want to store the entire email body in a field, but then want to compress it. Using Char() will not store the whole body, but will allow compression... using varchar() w...

I need help on INSERT command, two tables

Hi, I have two tables: SUBJECTS IDsubjects username subject GRADES IDgrades IDsubject grade Where SUBJECTS.IDsubjects and GRADES.IDsubject are connected forming a relational database. I want to insert a grade based on a user's subject but I don't know how to do that. I have three values: - username - subject - grade I want to INSER...

SQL Server how to control access to data between clients on the same database

Hi, We have a system with 2 clients (which will increase). These two clients connect to the same server/database, however neither should be able to see the others sensitive information. There is however some shared non sensitive information. There is also an administrative department who does work on behalf on both of the clients. They...

can we use set,bag,map for non collection relationship

Hi guys, Does set,bag while cascading is used for Ilist or Iset only. What if the entity is not a list, just a non collection relationship. In that case what should we use while cascading. ...

Tidy for SQL

I'm looking for a tool that that I can use to clean up (formatting, tabs etc...) my stored procedures and views. Is there anything like html's tidy, but for SQL which is free/open source? ...

What is the best way to store byte array in SQL database using NHibernate?

Hi, I have an array of bytes in my C# class, and need to persist it into a SQL Server 2005 database using NHibernate. What SQL data type should I use for the column, and how do I got about using NHiberante to do the persistance for me? If the answer is a custom NHibernate type, is there any sample code knicking around to do this? Would...

SQL Select with WHERE condition, what happens in the background?

Assume I do not have text indexing on. Let say I have: SELECT * FROM myTable WHERE myTable.columnA LIKE 'bobo' Will the SQL engine go through every row and only return those matching conditions or is SQL smarter and does do some hidden native indexing? I'm on MSSQL 2000, 2005, 2008 but if other versions of SQL have different approach...

Doctrine raw sql and prepared statements

I've got a Doctrine_RawSql query using prepared statements. However, they seem to get ignored when the SQL query is generated. But If I leave out the token values, I get an exception about number of bound variables not matching (so it's at least trying to sub them in). If I include these values inline, is Doctrine doing anything behind ...

Using Variables in a fill query in a TableAdapter

Hi, I’m using C# and Winforms. I’m trying to make a report that gives a list of people that need to renew their memberships if they expire within a user supplied date range. I've got a connection to an Access file, and I'm trying to set up a fill query for a TableAdapter, and I can’t figure out how to put a variable in my "WHERE" clause....

Combining XML with Reverse Paths

Hey everyone, I am looking for a way that I can query a database with multiple SQL Queries and then, once I have the results of the queries (in XML), merge the separate XML together into one XML document, using reverse paths. My reason for doing this is related to the concept of Parallel Details (same data, with different manipulations ...