sql

sql performance, visual studio

Hi there I'm using linq2sql and .net 3.5 with vs2010. I'm experiencing bad sql performance when i run my program through vs2010, but not when i execute the same debug enabled exe outside vs. Whats going on here? Any ideas? ...

There are fewer columns in the INSERT isn't the answer

Hello, I have an application that converts one database to another and one of the functions I use is insert_Note below. This application has multipule threads all inserting diffrent data into the new database. The code below works for a number of inserts ranging between 24 and 120 but then fails with the error: There are fewer columns ...

How to use concatenation '||' with distinct clause of SELECT query?

Hi, I get a missing expression error when I try, SELECT 'label1:'||distinct col1 from tab1; Is there a way to get around this error? Thanks in advance. Edit: The entire query is: SELECT 'label1:'||distinct col1 from tab1 order by col1; ...

Getting objects from a relational table in with Oracle pl/sql procedure.

I want to retrieve rows from an oracle table and convert them into objects. I am currently using a refcursor result and a datareader in c# to manually convert the rows to objects but this seems messy. Is their a better way of converting rows from a relational table to objects? EDIT: The project I'm on is not using any ORM tools so unf...

Is it possible to select from multiples tables, having theirs names as the result of a subquery?

I have some tables with the same structure and I want to make a select in a group of them. Rather than just making a loop to all of those tables, I would like to put a subquery after the FROM of the main query. Is it possible or it will fail? Thanks! (Using Oracle) Additional info: I don't have the name of the table right away! Th...

Sql server Encryption or security permissions

Just started looking into encryption using keys and certificates in sql server 2005/08 and although it looks very good I'm not too sure why I should use it over sql server security permissioning. For example, I have a table with sensitive data in, such as user-name/passwords. I can either encrypt the data using say ENCRYPTBYCERT, or s...

Time-out occurred while waiting for buffer latch type 2 for page (1:1535865), database ID 6.

Time-out occurred while waiting for buffer latch type 2 for page (1:1535865), database ID 6. This is an error message I got for five times while trying to create an index CREATE NONCLUSTERED INDEX YearIndx ON dbo.Papers ( PublicationYear ) the papers table is about 20,000,000 records and 175 GB Thank you in advance. ...

Manipulating the db with SQL Server 2005 - Django

Hi folks, I'm trying to accomplish the following: Grab the db schema Grab any constraints* Alter tables Add/Drop tables I'm currently using pyodbc backend for Django. I would like to perform all these tasks within a view file. I'm using the following in order to grab fields of tables starting with 'core_': SELECT table_name,or...

sql trigger error:invalid specification

Hi everyone, i am creating a trigger and receiving some error, which i m not able to understand. Pls can anyone help me with that. create or REPLACE TRIGGER trig_data BEFORE INSERT ON data_db REFERENCING OLD AS OLD AND NEW AS NEW FOR EACH ROW BEGIN SELECT RAHUL_SEQUENCE.NEXTVAL INTO :NEW.USERID FROM DUAL; END; E...

Update linked SQL server with parameters

I have two linked SQL servers and i am trying to issue an update on the other server but am getting an error "Statement(s) could not be prepared.", followed by "Must declare the scalar variable "@Shipper_Nbr"" The syntax i am using is: update DBSERVER.DBNAME.DBO.TABLE set Field = @Value WHERE ID = @id What is the correct way to do th...

Which RDBMS has the richest super-set of ANSI-SQL?

Back in 1989, when I used to program with Oracle 5.2.3 on UNIX and VAX/VMS platforms, I considered SQL*PLUS as having the richest super-set of built-in functions. ORACLE*FORMS also had the ability to embed SQL statements within triggers. That was then, 21 years ago. At present, which other RDBMS' have come close, have the same, or more f...

Converting int value to a char that is too small

Try the following on MSSQL 2005: select convert(char(2), 123) The key here is that char(2) is too small to accept the value '123'. I would expect to see a truncation error here, but instead the value "*" is returned. Update: A few of the answers showed how to cast in a way that will cause an error. That's not really what I need. We h...

MySQL: How to get a sequential number with rows?

How can I number my results where the lowest ID is #1 and the highest ID is the #numberOfResults Example: If I have a table with only 3 rows in it. whose ID's are 24, 87, 112 it would pull like this: ID 24 87 112 Num 1 2 3 The reason why I want this, is my manager wants items to be numbered like item1, item2, etc. I initially ...

Help with MYSQL query

In the table below +-------+-----------------------+ | id | timestamp | +-------+-----------------------+ | 1 | 2010-06-10 14:35:30 | | 2 | 2010-06-10 15:27:35 | | 3 | 2010-06-10 16:39:36 | | 4 | 2010-06-11 14:55:30 | | 5 | 2010-06-11 18:45:31 | | 6 | 2010-06-12 20:25:31 | +---...

Update using a subquery SQL PL/SQL

I am trying to update a table, but I can't get my syntax to work. I added new elements from a temp table to my element table and I want to update column_name in metadata_attribute and table_name in metadata_table table. This is what I have: UPDATE METADATA_ATTRIBUTE SET C.ELEMENT_ID = (SELECT ELEMENT_ID FROM ...

Is C++ OTL SQL database library using parameterized queries under the hood, or string concat?

I've been looking at the OTL library for C++ database access. I'm unsure of whether the query I pass in is converted to a parameterized query for the underlying database, or if it's basically just concatenating all the arguments into one big string and passing the query to the database that way. I see that the query you pass in to it c...

Problems making a fitnesse test...

Hello everyone!! I´m trying to do this test on fitnesse, but actually it inserts only the first one (|Execute|INSERT INTO restdb.labels (id, label_name) VALUES (1, "label_test1")|) Apparently the other are ignored... I´ve debugged it using eclipse and I´m checking everything on HEIDSQL. !2 Add Credit to account !3 Insert the entities ...

Hint for a C# and also an SQL Puzzle

I was browsing SO careers and came across a job that had a pdf with a couple of puzzles they wanted applicants to send in. Although I'm not interested in the job, I read the questions anyway and had a play in Visual Studio / SMSS. The first question was fairly easy to solve although I couldn't think if any way to optimise it (I solved ...

SQL statement to select group containing all of a set of values

In SQL Server 2005, I have an order details table with an order id and a product id. I want to write a sql statement that finds all orders that have all the items within a particular order. So, if order 5 has items 1, 2, and 3, I would want all other orders that also have 1, 2, and 3. Also, if order 5 had 2 twice and 3 once, I'd want ...

SQL script how to add a tab or new line within script

I have a SQL script that acquires table names and creates trigger for those tables. When I open the trigger after creating it all of the code is on one line. How would I go about adding tab and new line characters within the script to make the trigger more readable. Example code: SET @SQL = 'ALTER TRIGGER [dbo].[TRG_' + SUBSTRING(@TABL...