sql

Run SQL statements from ASP.net application

I need to run sql statements from the application itself. i.e. the user can go into the asp.net applciation, gets a box and can run sql statements from there I am already doing something like this http://stackoverflow.com/questions/1858329/can-i-rollback-dynamic-sql-in-mssql-tsql/1860334#1860334 That is running dynamic sql is there a ...

Which ORM Supports this

I have an optional part of query that needs to be executed on a certain condition. Here is the example code: int cat = 1; int UserID = 12; string qry = "select * from articles"; if(cat > 0) qry += " where categoryID = " + cat; if(UserID > 0) qry += " AND userid = " + UserID; //The AND may be a WHERE if first condition is fals...

Sending emails from sql sever

What is the best way to send email from sql server 2008 (script). Any sample or online links please. ...

How to get date from datetime in sql

hi guys, I have a field named 'CreatedDate' in table.It contain value as 2009-12-07 11:02:20.890.My search parameter is createddate.Parameter contains value as 2009-12-07.My parameter contains only datepart.If my parameter contains only 2009-12-07 its not giving result.Only when time is included its giving result. My query is Se...

What SQL queries will help analyse a membership base?

At our sports centre, I would like to analyse the number and types of subscriptions our members have, but I'm having trouble with the exact SQL queries. A "subscription" is an entry pass that lets you into specific activities in our sports centre. They have a start and end date, representing the period they are valid. They have an assoc...

MySQL stored procedure: variable in WHERE clause?

Can you not do the following w/ MySQL stored procedures?/ DROP PROCEDURE IF EXISTS `test`; DELIMITER // CREATE PROCEDURE TEST (team varchar(30)) BEGIN SELECT * FROM TEAMS WHERE TEAM_ID = @team; END // Where @team (or team) is the variable passed to the stored procedure? ...

Remove trailing empty space in a field content

I am using SQL server MSDE 2000. I have a field called notes of type nvarchar(65). The content is 'Something ' with an extra space after the content (quotes for clarity) in all the records. I used the following command. UPDATE TABLE1 SET notes = RTRIM(LTRIM(notes)) But it does not work. Is there any alternate way to do it? ...

MySQL to PostgreSQL: GROUP BY issues.

So I decided to try out PostgreSQL instead of MySQL but I am having some slight conversion problems. This was a query of mine that samples data from four tables and spit them out all in on result. I am at a loss of how to convey this in PostgreSQL and specifically in Django but I am leaving that for another quesiton so bonus points if ...

data mining problem for sql

I only can use Compare , Count ,Find ,Join , Save and sort to do this. question: What would you do to determine how many existing customers purchased another plan / phone? Visitors – anyone who visited the site (anyone on site) Prospects – any consumer who visited the site, but did not log into an account (logging into an account wo...

can i combine these update queries into one query

In an MS-Access database with Table called NewTable3 can i combine these 3 sql queries into one query UPDATE NewTable3 SET SAO = '0' WHERE SAO LIKE '-'; UPDATE NewTable3 SET SAO = '0' WHERE SAO LIKE 'NULL'; UPDATE NewTable3 SET SAO = '0' WHERE SAO LIKE 'NA'; ...

Combining "LIKE" and "IN" for SQL Server

Is it possible to combine LIKE and IN in a SQL Server-Query? So, that this query SELECT * FROM table WHERE column LIKE IN ('Text%', 'Link%', 'Hello%', '%World%') Finds any of these possible matches: Text, Textasd, Text hello, Link2, Linkomg, HelloWorld, ThatWorldBusiness etc... ...

index with multiple columns - ok when doing query on only one column?

If I have an table create table sv ( id integer, data text ) and an index: create index myindex_idx on sv (id,text) would this still be usefull if I did a query select * from sv where id = 10 My reason for asking is that i'm looking through a set of tables with out any indexes, and seeing different combinations of select queries...

how to do complete multiple replaces throughout table in ms-access

i am a little confused in finding out what would be the best way to replace all occurances of 1. Blanks 2. - 3. NA from all collumns of TableA with question mark ? charachter. Sample Row in orignal tableA 444586 RAUR <blank> 8 570 NA - 13 - SCHS299 MP 339 70 EN <blank> Same Row in Expected TableA 444586 RAUR ? 8 570 ? ? 13 ? SCH...

Alter column's default value

Hi I have a table which has a column 'CompanyID int not null' and its default value is set to 10. Now I want to write a query which will alter this default value to 1. How can can I do it? Any help will be appreciated. I am using SQL server 2000. ...

Is there a performance difference between select * from tablename and select column1, column2 from tablename?

Possible Duplicates: Select * vs Specifying Column Names Which is faster/best? SELECT * or SELECT column1, colum2, column3, etc. Is there a performance difference between select * from tablename and select column1, column2 from tablename? When it is select * from, the database pulls out all fields/columns which are more than...

Performing PostgreSQL LEFT OUTER JOINS and CASEs in Django.

So I have a fairly involved sql query here. SELECT links_link.id, links_link.created, links_link.url, links_link.title, links_category.title, SUM(links_vote.karma_delta) AS karma, SUM(CASE WHEN links_vote.user_id = 1 THEN links_vote.karma_delta ELSE 0 END) AS user_vote FROM links_link LEFT OUTER JOIN auth_user ON (links_link.user_id = a...

Object reference not set while SQL manager says it is

Lately I have run in a strange NullReferenceException. It pops up only occasionally why it is so hard to debug it for me. Today it happened again and I want to fix it now I have the error. I have the following setup: An asp.net view with relevant code: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<WerkStageNu.Prof...

Forcing a datatype in MS Access make table query

I have a query in MS Access which creates a table from two subqueries. For two of the columns being created, I'm dividing one column from the first subquery into a column from the second subquery. The datatype of the first column is a double; the datatype of the second column is decimal, with scale of 2, but I want the second column t...

Updating Uncommitted data to a cell with in an UPDATE statement

I want to convert a table storing in Name-Value pair data to relational form in SQL Server 2008. Source table Strings ID Type String 100 1 John 100 2 Milton 101 1 Johny 101 2 Gaddar Target required Customers ID FirstName LastName 100 John Milton 101 Johny Gaddar I am following the strategy given below, Populate the Customer t...

Sqlite API boolean access

This should be an easy question I figure, but I hadn't found this answered else where surprisingly, so I'm posting it here. I've inherited a Sqlite driven database which contains boolean columns in it, declared like this: CREATE TABLE example ( ex_col BOOLEAN NOT NULL DEFAULT 0, ); This table is trying to be accessed via the sqlite...