sql

DB2 Implied Decimal

Running DB2 8.2 Fixpak 18 for LUW, I need to convert a DECIMAL field to a IMPLIEDDECIMAL for a file export. I cannot find anything in the documentation online, please help. ...

Problem with SQL statement

Hello, I have the following code: if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) { // Setup the SQL Statement and compile it for faster access const char *sqlStatement = "select ZWAYPOINT_X, ZWAYPOINT_Y from ZWAYPOINT where ZMAP_ID %@", mapID; sqlite3_stmt *compiledStatement; if...

Speed Performance In Recursive SQL Requests

Hi, I have so category and this categories have unlimited sub category. In Database Table, Fields are ID, UpperID and Title. If I call a category and its subcategory in DataTable with recursive method in program(ASP.NET project) performance is very bad. And many user will use this application so everything goes bad. Maybe All categorie...

How to truncate the text returned for a column in a MySQL query

I have a table in a MySQL database that I am running simple SELECT queries on (for quick diagnostics/analysis - since I am not running phpmyadmin on the server - for security reasons). I would like to be able to truncate the returned data using something like this: select id, LEFT(full_name, 32), age FROM user where user is a table t...

Creating A Script To Replicate A Table And Its Contents?

I know you can create a script to replicate a table using: right click table > script table as > create to > new query editor window But how can I generate a script that contains a bunch of insert commands for each row in the table? Table1 Id1, Row1 Id2, Row2 Id3, Row3 Insert into Table1 values(Row1); Insert into Table1 values(Row2);...

Is it possible to tell SSMS not to check if a column exists in a t-sql script?

Hi, I tried to google it, but din't find a way I have a t-sql script that adds a new column to a table, then fills that columns with values depending on some other columns in the same table and finally removes some columns. This all works fine. The problem occures when I want to run the script again. I have a if clause that checks if ...

Is _mmServerScripts necessary?

When developing sites using Dreamweaver, it creates a _mmServerScripts directory on the root of your site. We've been reading that this folder contains SQL statements that are vulnerable to attack. We would like to avoid this all together, if possible. Is this folder even necessary? Can you do anything to Dreamweaver to tell it to never ...

MSSQL to MySQL API conversion layer

Hi, I'm looking for a program that can emulate, impersonate a MSSQL server and convert and write the queries to a MySQL database. Thus allowing me to configure client applications developed for MSSQL database systems only, to connect to the emulator and thus writing and reading the MySQL based records. Any help will be highly appreciat...

Sql query join nearest date

I have a sqlite query that I'm trying to write. I have two tables: TableA (sales): id sales date TableB (goals): id goal date I'm selecting from TableA like this: SELECT id,sales,date FROM TableA Now to the "tricky" part. I need to join TableB to the query because I need the goal field in TableB for each row in TableA. TableB only co...

Can I do pivot with mysql 5.1?

Can I do pivot with mysql 5.1? (or emulate it somehow). ...

Content Indexer/Indexing Service - database content?

We've been using content indexer successfully for years to provide search. This works well because a significant amount of content is cached on disk. However, I'd like to move away from this paradigm. Is there anyway I can keep content indexer and have it index "pages" stored in SQL Server? ...

SQL Server 2K - Insert explicit value for timestamp column?

Hey all, I'm curently working on a project where I need to transfer data (with some minor transformations) from one database to another. Everything was going just fine when I hit my first Timestamp column... It seems SQL Server doesn't want me to use explicit values for this type of column and it, instead, wants to generate its own. ...

How to obtain NHibernate generated SQL in code at runtime?

I know you can view the NHibernate generated SQL by hooking it up to log4net or piping it out to the console ("show_sql" option), but is there any way to obtain the generated SQL in code at runtime? What I would like to be able to do is take an ICriteria object (or IQuery) and dump the generated SQL to the screen or custom log (not log4...

SQL Reading from a DB problem using a DataReader

I have a table of Users (tblUsers) which contains details of University staff. I am trying to populate a text box with the names of lecturers associated with a selected module. I am getting all UserIDs associated with a particular module, testing if the User is a lecturer, if so then I add the ID to an ArrayList. I then iterate throu...

SQL: Best approach to Select and Insert from multiple tables

What do you guys think would be the best approach here? I have about 30 SQL tables that is basically referenced by a [lookup] table. I have to do an insert in another table [FinalTable] for each row in the [lookup] table. Now the [lookup] table looks something like this. ID, Zipcode, tableID 1, 60453, 1 2, 90210, 1 3, 60453, ...

SQL Server: Using a case statement to see if a date is NULL and if it is returning ' '

I have a column in my select statement that looks like this: SELECT CASE WHEN fu.SentOutDate IS NULL THEN '' ELSE fu.SentOutDate END This returns 1900-01-01 00:00:00.000 for the ones that would otherwise be NULL I know this because when I put in just fu.SentOutDate it comes up as NULL Why does this happen and how can I just get it t...

Is it better to do a select count then if before doing a delete or just blindly call delete?

I'm looking for a best practice / thoughts on if it is better to do a select count and checking if the result is > 0 before calling a delete or if it would be better to just blindly fire a delete statement at the database even if the data doesn't exist. In our case most of the time data will NOT exist. So what is better: Option 1: c...

The 'System.Web.Security.SqlMembershipProvider' requires a database schema compatible with schema version '1'.

I have a SQL Server 2008 DB with many tables filled with data and I used SQL Server Management Studio to generate a SQL dump by using the Script Wizard : Tasks -> Generate Scripts -> Script All objects in the selected database and also selecting the option to Script Data. I made sure to change the value of "Script for Server Version" to ...

What is bltoolkit's BLTgen tool and how it should be used?

I guess it is something like sgen.exe which generates some serialization classes in separate assembly. Is that it? Should generated assembly be referenced? If so, by which project? I have noticed that some LINQ queries are very slow, when executed for first time. Maybe bltgen tool can help? I'll start a bltoolkit blog when I find all t...

updating the few highest rows in a table using mysql 5.1.41

I have a table with several hundred rows. I want to take the top 20 based on the value of column num and replace num with a number. What I tried to do (which didn't work) was: UPDATE table SET num = 95 WHERE id IN (SELECT id FROM table ORDER BY id DESC LIMIT 20) Any suggestions? ...