I have an international company that has recently been added, which is named "BLA "BLAHBLAH" Ltd. (The double quotes are part of the name. )
Whenever a user tries to search for this company, by entering "Blah, or something to that affect, the search fails with a syntax error in SQL server.
How can I escape this so the search will not f...
I have several instances where that a section of legacy sql statements is based on a dependency. for example.
if (x !=null)
{
SQL = "SELECT z WHERE x > y";
}
else
{
SQL = "SELECT z WHERE x <= y";
}
SQL2 = SQL + " JOIN a ON b";
I am creating PreparedStatements out of this legacy code. What is the best-practice here. Should I cre...
In SQL server you can use the DATENAME function to get the day of week as a string
declare @date datetime
set @date = '12/16/08'
select datename(dw, @date)
which returns "Tuesday"
and you can use the DATEPART function to get the day of week as an integer
declare @date datetime
set @date = '12/16/08'
select datepart(dw, @date)
Whic...
Background:
I'm working with a program coded in C++ which uses ODBC on SQL Native Client to establish connections to interact with a SQL Server 2000 database.
Problem:
My connections are abstracted into an object which opens a connection when the object is instantiated and closes the connection when the object is destroyed. I can see t...
I need to design a program using python that will ask the user for a barcode. Then, using this barcode, it will search a mysql to find its corresponding product.
I am a bit stuck on how to get started. Does anyone have any tips for me?
...
Let's say I have a table called Product, with three columns: Id, CustomerId, Name. Id is the primary key. The schema is outside of the control of my group, and we now have a requirement to always provide CustomerId as a parameter for all queries (selects, updates, deletes). It's a long story I'd rather not get into ... it involves trig...
I'm building a site where users can track their collection of figures for Dungeons & Dragons (www.ddmdb.com). The models/relationships involved in this funcitonality are the following:
User:
id
login (username)
a bunch of other fields
Miniature:
id
name
number (# in the set, not count)
release_id (foreign key)
a bunch of other fi...
Hi
I have a database for an E-commerce storefront. MSSQL 2008.
I have a table called Products and a table called Tags. This is a many to many relationship that is bound together by a table called ProductTags.
Products:
id, name, price
Tags:
id, name, sortorder, parentid(allow nulls)
ProductTags:
productid, tagid
I'm trying to creat...
I have a bunch of pretty large CSV (comma separated values) files and I want to analyze them. SQL queries are ideal for this. So far I have been using MS Access to import the CSV files and execute queries on them. However, in addition to having a very bad SQL editor and having stupid arbitrary rules about when a query/table can be opened...
A simple stupid "UPDATE table SET something=another WHERE (always true)" in accident will easily destroy everything in the database. It could be a human mistake, an SQL injection/overflow/truncation attack, or a bug in the code who build the WHERE causes.
Are popular databases provide a feature that protect tables by limit maximum numbe...
Consider this example table (assuming SQL Server 2005):
create table product_bill_of_materials
(
parent_product_id int not null,
child_product_id int not null,
quantity int not null
)
I'm considering a composite primary key containing the two product_id columns (I'll definitely want a unique constraint) as opposed to a sep...
I need to query a table for values given a string. The table is case sensitive but I want to do a ToLower() in the comparison.
Suppose I have a classes table with the following data.
class teacher
-----------------
Mat101 Smith
MAT101 Jones
mat101 Abram
ENG102 Smith
My query should be something like
Select teacher From c...
I am attempting to get the information from one table (games) and count the entries in another table (tickets) that correspond to each entry in the first. I want each entry in the first table to be returned even if there aren't any entries in the second. My query is as follows:
SELECT g.*, count(*)
FROM games g, tickets t
WHERE (t.g...
Is there any way to have a Windows batch file directly input SQL statements without calling a script? I want the batch file to login to SQL and then enter in the statements directly.
EDIT: I'm using Oracle v10g
...
I'm looking for ways to display a single row of data as a single column (with multiple rows). For example,
FieldA FieldB
------- ---------
1 Some Text [row]
Header Value [col]
------ ------
FieldA 1 [row1]
FieldB SomeText [row2]
Is there a way to do this with SQL Server 2005?
...
Simply put, I have a table with, among other things, a column for timestamps. I want to get the row with the most recent (i.e. greatest value) timestamp. Currently I'm doing this:
SELECT * FROM table ORDER BY timestamp DESC LIMIT 1
But I'd much rather do something like this:
SELECT * FROM table WHERE timestamp=max(timestamp)
Howeve...
Hi,
how do we call a C function from an SQL script?
int get_next_fbill_b2kId_seq_num(b2kIdType seq_val,bankIdPtrType bank_id)
{
validate_dc_alias(dcAlias);
tbaDateType sysDate;
tbaGetSystemDateTime(sysDate,NULL,NULL); /* returns in TBA date format */
sysDate[10] = EOS;
get_seq_value(next_num_char, 0, FBILL_B2KID_SR...
Can I create a macro written in C# for Excel that allows me to export a cell's data to a SQL Server or Access database?
Basically, I'd like to create a button in Excel that saves the data in certain cells to a database. Can this be done?
Instead of creating a UI from scratch for a program, I've decided using Excel as the user environm...
I use C# to make connection to a db and then a Ad hoc SQL to get data. This simple SQL query is very convenient to debug since I can log the SQL query string. If I use parametrized SQL query command, is there any way to log sql query string for debug purpose?
...
I have a date variable as 24-dec-08
I want only the 08 component from it.
How do I do it in a select statement?
e.g.:
select db||sysdate
(this is the component where I want only 08 from the date)
from gct;
How do i do it?
...