sql

Dash in a field name in access database table

Hi, Im having problems retrieving a field from my ms-access database. The table name is TEST and one of the field's name is HD-TEST When i do: SELECT * from TEST where TEST.HD-TEST='H' and i execute the query, ms-access shows me a dialog expecting the parameter HD. Do you know what could be the reason? Thanks a lot. Kind Regards. ...

What is this process in Sql Server Activity monitor?

There is a process that seems to be running all the time in SQL Server 2005 activity monitor. Double clicking on it produces the following query: CREATE TABLE #tmpDBCCinputbuffer ([EVENT TYPE] NVARCHAR(512), [PARAMETERS] INT, [EVENT Info] NVARCHAR(512)) INSERT INTO #tmpDBCCinputbuffer EXEC ('DBCC INPUTBUFFER(58)') SELECT [EVEN...

NHibernate - Mapping same entity to many tables

Hi, I'm working on an application that has a data publication mecanism that I designed & implemented. It allows one master instance of the app to feed data to many subscriber instances. This is implemented by loading the master's data into a set of temporary import tables that have the same exact schema on the subscriber. The merge proc...

Inline SQL vs Stored Procedures

I know this is an age old debate but I'm curious as to what others do. I tend to use stored procedures for complex reports, user verification and other queries that aren't your typical SELECT, INSERT, UPDATE, and DELETE statements. It's my understanding that SPs are faster because they save the execution stack but is there a tangable di...

How can I optimize this horrendously inefficient User Defined Function in SQL Server 08

Is there anyway to optimize this horrible inefficient UDF in SQL Server 08. I am fairly new to UDF's and especially looking at them for optimizations. UPDATE: Should I be sending a column to a function like this if I wanted to perform it on each row and each column in a query? Is there a better way to go about this? Thank You ** @v...

Restricting a LEFT JOIN

I have a table, let's call it "a" that is used in a left join in a view that involves a lot of tables. However, I only want to return rows of "a" if they also join with another table "b". So the existing code looks like SELECT .... FROM main ... ... LEFT JOIN a ON (main.col2 = a.col2) but it's returning too many rows, specifically o...

How to get N rows starting from row M from sorted table in T-SQL

There is a simple way to get top N rows from any table: SELECT TOP 10 * FROM MyTable ORDER BY MyColumn Is there any efficient way to query M rows starting from row N For example, Id Value 1 a 2 b 3 c 4 d 5 e 6 f And query like this SELECT [3,2] * FROM MyTable ORDER BY MyColumn /* hypothetical syntax */ queries...

Access remote sql server using VB.NET

I've found a few examples of using vb.net to access an sql database, so far none of them have worked . They all involve using DataReaders. Maybe its the fact that the sql db is not on the same machine as the application. I was just wondering if anyone had a more comprehensive example of using VB.NET to access a remote sql server. Thank...

MS Sql: Conditional ORDER BY ASC/DESC Question

I want to to make to make the ordering in my query conditional so if it satisfiess the condition it should be ordered by descending For instance: SELECT * FROM Data ORDER BY SortOrder CASE WHEN @Direction = 1 THEN DESC END ...

Automatically Generate SQL from existing MS Access table

I've just designed a large database by playing around in MS Access. Now that I'm happy with the design, I need to be able to generate this same database (tables, relationships, etc.) from code. Rather than hand-writing the SQL CREATE statements (which will be long, tedious, and error-prone process), I was wondering whether there was a s...

Is the CHAR datatype in SQL obsolete? When do you use it?

The title pretty much frames the question. I have not used CHAR in years. Right now, I am reverse-engineering a database that has CHAR all over it, for primary keys, codes, etc. How about a CHAR(30) column? Edit: So the general opinion seems to be that CHAR if perfectly fine for certain things. I, however, think that you can design a da...

Returning a row more than once in SQL from a single table?

Lets say I have a table CUSTOMERS with a key of CUSTOMER_ID. I would like to return multiple rows based on a query: SELECT NAME FROM CUSTOMERS WHERE CUSTOMER_ID in (130,130); This always returns a single row that matches although I would like it to appear twice. My motivation is a bit convoluted and far more complex than the tiny exa...

SQL Server Indexes

what is the difference between clustered index scan and clustered index seek? ...

To change date format in sql

hi guys, I have date in mm/dd/yyyy format in database.I want to display in form as dd/mm/yyyy. Can anybody help?I want to get time along with date. ...

Zend Framework: How best to go about retrieving the first name of an authenticated user?

I can get the username by doing this: public function indexAction() { $this->view->username = Zend_Auth::getInstance()->getIdentity(); } "username" is the column in the table that validates the identity. "firstname" is also a column in that table. Does Zend_Auth only store the username? Or is there a way to access other columns fr...

TPC or other DB benchmarks for SSD drives

I have been interested in SSD drives for quite sometime. I do a lot of work with databases, and I've been quite interested to find benchmarks such as TPC-H performed with and without SSD drives. On the outside it sounds like there would be one, but unfortunately I have not been able to find one. The closest I've found to an answer was t...

How to implement a Keyword Search in MySQL?

HI all, I am really a new sq l programmer, can some one help me in solving this. I have a table job where the fields are id,position,category,location,salary range, description, refno. I want to implement a keyword search from the front end. The keyword can be reside in any of the field of the said table. ...

Where do you put your SQL Queries?

We are using a mix of EJB 2.1 and JDBC to access our Database. I just had a co-worker mention the idea to put his SQL Queries into a .properties file. How and Where do you put your SQL Queries? EDIT: Do you inline it with the code, put into the class instantiation? ...

Map raw SQL to multiple related Django models

Due to performance reasons I can't use the ORM query methods of Django and I have to use raw SQL for some complex questions. I want to find a way to map the results of a SQL query to several models. I know I can use the following statement to map the query results to one model, but I can't figure how to use it to be able to map to relat...

SQL to generate report of entity-attribute-value structured data

I have 3 tables: Productmaster: ProductId PName PDescription Attributes: AttributeID attName ---- ---- 1 Brand 2 Category 3 Artist ProductAttributeValues paId ProductId AttributeID AttributeValues A product can have multiple attributes. Here's the desired output: ProductId ...