sql

How can i solve "An explicit value for the identity column in table"?

if i try to add some data into my table error occurs: Error:Msg 8101, Level 16, State 1, Line 1 An explicit value for the identity column in table 'ENG_PREP' can only be specified when a column list is used and IDENTITY_INSERT is ON. insert into ENG_PREP VALUES('572012-01-1,572012-01-2,572012-01-3,572013-01-1,572013-01-2', '', '500', ...

SQL - Link to more table information

I have a datagrid with 3 of 5 fields from a SQL table. The first databound was changed to an asp:hyperlink so the field can be clicked. What I want to do is, when the user clicks an object in the field, it sends the ID to another page. From there, it uses the request in order to display the required information which is found in the same...

Self referencing update SQL statement for Informix

Need some Informix SQL... Courses get a regular grade, but their associated labs get a grade of 'LAB'. I need to update the table so that the lab grade matches the course grade. Also, if there is no corresponding course for a lab, it means the course was canceled. In that case, I want to place a flag value of 'X' for its grade. Exam...

SQL Query takes about 10 - 20 minutes

I have a select from (nothing to complex) Select * from VIEW This view has about 6000 records and about 40 columns. It comes from a Lotus Notes SQL database. So my ODBC drive is the LotusNotesSQL driver. The query takes about 30 seconds to execute. The company I worked for used EXCEL to run the query and write everything to the works...

server error while defing foreign key...

> i am getting following error in sql > server express while defining foreign > key could any body resolve my problem > > > 'tbl_branch' table saved successfully > > 'tbl_students' table > > - Unable to create relationship 'FK_tbl_students_tbl_branch'. > > Introducing FOREIGN KEY constraint > > 'FK_tbl_students_tbl_branch' on table > ...

Stored procedure optimization

Hi, i have a stored procedure which takes lot of time to execure .Can any one suggest a better approch so that the same result set is achived. ALTER PROCEDURE [dbo].[spFavoriteRecipesGET] @USERID INT, @PAGENUMBER INT, @PAGESIZE INT, @SORTDIRECTION VARCHAR(4), @SORTORDER VARCHAR(4),@FILTERBY INT AS BEGIN DECLARE @ROW_STAR...

Keep text formatting in Sql

I have a text area that inserts it's content into a SQL table. Is there a way to keep the formatting of the text and then use it in HTML? ...

SQL bottleneck, how to fix

This is related to my previous thread: http://stackoverflow.com/questions/3069806/sql-query-takes-about-10-20-minutes However, I kinda figured out the problem. The problem (as described in the previous thread) is not the insert (while its still slow), the problem is looping through the data itself Consider the following code: Dim rs ...

determine if a restaurant is open now (like yelp does) using database, php, js

i was wondering if anyone knows how yelp determines what restaurants are "open now"? i'm developing a similar application using html/javascript/php. i was going to have a column in my database for each day, with comma separated hours written in "2243" format (10:43 pm). so for example if a restaurant is open for lunch and dinner it might...

Modifying Gridview select action?

I have a gridview and when a user selects a row I want to change the view in my multiview and display several new gridviews. A user would be clicking on a computer, and then it will display the computer stats/atached devices/etc. The new gridviews are going to need a column from the row that was selected, how do I get that? Thanks. ...

How to store a list in a column of a database table.

Howdy! So, per Mehrdad's answer to a related question, I get it that a "proper" database table column doesn't store a list. Rather, you should create another table that effectively holds the elements of said list and then link to it directly or through a junction table. However, the type of list I want to create will be composed of un...

Oracle locking with SELECT...FOR UPDATE OF

I'm selecting from tables FOO and BAR. I'd like to lock the records of FOO which are being returned, but I don't want the records of BAR to be locked. cursor c_foobar is select foo.*, bar.* from foo, bar where foo.id = bar.foo_id for update of <what should I put here?> It seems like I need to specify individual columns, but I want t...

MySQL Wildcards * and %

What is the difference between % and * wildcards in MySQL? In a query like so : "SELECT * FROM $table WHERE MATCH (message) AGAINST('$string*' IN BOOLEAN MODE)" ...

Bulk updating an sql server table using xml

How can i update bulk data in sql server 2005 by sending the data in XML form ? i am able to insert bulk data into the table, but i am not getting idea to update the data. ...

Which are the criteria for defining " as mandatory or not in a Postgresql query?

I am getting started with Postgresql, I converted a MS SQL DB but I cannot understand why SELECT * FROM MYTABLE doesn't work while SELECT * FROM "MYTABLE" does Moreover from another machine, connecting to the same DB I can run SELECT * FROM MYTABLE --(without ") All tests were done by using PGAdmin III Windows client. Postgresq...

Very Different Execution Times of SQL Query in C# and SQL Server Management Studio

I have a simple SQL query that when run from C# takes over 30 seconds then times-out every time, whereas when run on SQL Server Management Studio successfully completes instantly. In the latter case, a query execution plan reveals nothing troubling, and the execution time is spread nicely through a few simple operations. I've run 'EXEC ...

Search sort by parameter match count in the query? PostgreSQL

I am working on a search query in PostgreSQL, and one of the things I do is sort my query results by the number of parameters matched. I have no clue how this can be done. Does anyone have a suggestion or solution? Table brand color type engine Ford Blue 4-door V8 Maserati Blue 2-door V12 Saturn G...

SQLAlchemy: Inserting the results of a query into another table

So I have some results which I've got from the install table, like so: install = metadata.tables['install'] results = session.query(install) #<sqlalchemy.orm.query.Query object> I'd like to insert these same results into the install_archive table. I'm not entirely sure how to do this, because I don't want to duplicate the schema b...

Microsoft.SqlServer.Management.Smo.Transfer class

I'm trying to copy sql db between servers using Smo.Transfer class. And it's ok when you're copying absolutely normal database. It works. But what if your data inconsistent? For example I have a function and it gets the value from a table and non-existed column (someone renamed the column and now the function wouldn't work). But if yo...

Can I lock rows in a cursor if the cursor only returns a single count(*) row?

I would like to restrict users from inserting more than 3 records with color = 'Red' in my FOO table. My intentions are to A) retrieve the current count so that I can determine whether another record is allowed and B) prevent any other processes from inserting any Red records while this one is in process, hence the for update of. I'd l...