sql

How to control ExecuteNonQuery

I mean hypothetically is it possible to control query execution? For example I got a big query and it does a lot of things but suddenly it gets an error, but I don't want to stop its execution, I just wanna skip that step and continue further. Or I want to let the user know what's going on, what's actually is happening on the server ri...

Simulating variable column names in sqlite

I want to store entries (a set of key=>value pairs) in a database, but the keys vary from entry to entry. I thought of storing with two tables, (1) of the keys for each entry and (2) of the values of specific keys for each entry, where entries share a common id field in both tables, but I am not sure how to pull entries as a key=>value ...

How can I do a search of the text of all Stored Procedures in a SQL database

In Visual Studio 2k8, I press Ctrl-F and then type some text I want to search for in my project. I can quickly search many files at once. I have a SQL Server with some stored procedures. How can I easily search my stored procedures for arbitrary strings? I know that I can list the text of one stored procedure in SQL Server Studio and...

MySQL - Is it possible to get all sub-items in a hierarchy?

I have looked at this: http://stackoverflow.com/questions/197362/select-products-where-the-category-belongs-to-any-category-in-the-hierarchy And it is talking about CTE, which doesn't exist in MySQL. I have structure like: category_id | parent_category_id | name I want to retrieve all the sub-categories ids of a given category_id. I...

Why should i use 1 table instead of two?

I have two tables called (Up|Down)Vote, you can do BOTH upvote and downvote thus it isnt one table with a bool. People suggested i should use one table called votes and have a field called type. Why should i do this? I think writing the unique table name is easier then writing Vote then the extra where statement (type & upOrDownTypeBit)...

How do I add to each row in MySQL?

We have a column that is a simple integer. We want to add to each row the value 10. How do we do it in sql for the MySQL database? Actually we have another column that needs to do the same thing, and it is a date. We need to add a month to the date. How to do that? ...

SQLCE Local Application Help

Hi, I'm here for a trouble with SQLCE on a C# application, this is a really simple question, at first I was trying to do an INSERT into a table, but it didn't do it, so I searched and the solution was to put the literal string to connect to the database. try { cnTrupp.Open(); SqlCeCommand com = new SqlCeCommand("INSERT INTO tip...

t-sql string & table column manipulation

DETAILS table has following columns Title First Second Third Fourth Fifth ------------------------------------------ A null null null null null input variable -------------- @columns = 'Title, Third, Fourth' I want to generate ouput as @allcolumns = 'Title, Third, Fourth, First, Second, Fifth' Variable @allco...

IN vs OR in the SQL WHERE Clause

Hi, When dealing with big databases, which performs better, IN or OR in the SQL Where-clause? Is there any difference about the way they are executed? ...

Left Join problem with where AND

Here is some hardcoded syntax. IPAddr is an int, this is sqlite and will be ported to mysql. The syntax doesnt work with AND V.IPAddr <> 0. Possibly because V is a left join and may not exist (null?). How do I get it to to succeed when V == null || V.IPAddr <> Val? select Post.id, name, body, (select count() from Votes where id=P...

Deleting all records of a table that are not referenced from another table

2 tables: items(id, ...) users(id, item_id, ...) How do you delete all records in items that are not referenced from users? ...

HOw to Save or update dynamically created values to Sql Server Database using Stored Procedures

My scenario.... I dynamically(dicval.add(Tkey,Tvalue) create set of columns and now i need to insert values and save those values using Stored procedures..how to achieve this ...

MySQL Query to Update a Field with data from another Field when two Fields Match

Hey, I need to update the content of one data field in a table with the content of another field in a table every time two separate fields, one on each table, match up. I've been trying this syntax but I just can't get it to work properly without giving me an error. UPDATE table1 SET field1 = table2.field1 FROM Table1,Table2 WHERE Table...

help for a JOIN query

Hi, i've this 3 following table table ads ... categoryID subcategoryID table category categoryID description table subcategory subCategoryID description How can i JOIN this 3 table to have all field from ADS and category description and also subcategory description... (when i use sql server, i can "design" the relations, but now,...

Is it bad to not use normalised tables in this database?

I recently learned about normalisation in my informatics class and I'm developing a multiplayer game using SQLite as backend database at the moment. Some information on it: The simplified structure looks a bit like the following: player_id | level | exp | money | inventory --------------------------------------------------------- ...

What permissions should be granted to the remote user to do anything with "the database" and no other?

What permissions should be granted to the remote user to do anything with the database "123" in SQL Server 2005 Express using SQL Server Management Studio Express such that the remote user cannot do anything to any other database? I would also like that the remote user cannot see the other databases. That is "123" is for the user login...

Nullable vs. non-null varchar data typyes - which is faster for queries?

We generally prefer to have all our varchar/nvarchar columns non-nullable with a empty string ('') as a default value. Someone on the team suggested that nullable is better because: A query like this: Select * From MyTable Where MyColumn IS NOT NULL is faster than this: Select * From MyTable Where MyColumn == '' Anyone have any ex...

I have sql query but how is the rest

I have following sql which is show previous days records from table. SELECT * FROM tblMeter WHERE (Date >= DATEADD(day, DATEDIFF(day, 1, GETDATE()), 0)) AND (Date < DATEADD(day, DATEDIFF(day, 0, GETDATE()), 0)) But how can I collect records with datetimepicker value in vb.net. Any help will be appreciated. Thanks ...

Using Command.Prepare with a SELECT, do I need to specify the SELECT columns as output parameters?

I'm trying to use Command.Prepare with a CommandType.Text query that has a single input parameter. The SELECT has several columns that I am extracting with a DataReader. Do I need to specify each of the select columns as output parameters before calling Command.Prepare()? Even if I don't need to specify them, will performance improve ...

How to reverse a field in SQL Server 2008

How to reverse a field in SQL Server 2008 ...