sql

Insert into MySQL tables with JOIN?

I have these tables: http://stackoverflow.com/questions/2104063/my-final-mysql-db-could-someone-check-if-the-tables-are-correctly-made How can I make an Insertion of an ad here? Is join used on insert also? Thanks Clarification: I need to insert values into multiple tables here, and don't know how to do it else than using multiple IN...

Remove bias from the monthly totals

In order to remove the bias introduced by the differences in the number of days in the months and years (in case of leap years), from monthly total comparisons of arbitrary quantities and assuming, for example, a table named My_Table with a datetime column named order_date, and an integer one named revenue, I use the following query to g...

Sql indentation in SQL Server Management Studio

Folks, is there a tool to format/indent SQL Server queries in query window ? TIA ...

dynamically varied number of conditions in the 'where' statement using LINQ

I'm working on my first project using LINQ (in mvc), so there is probably something very simple that I missed. However, a day of searching and experimenting has not turned up anything that works, hence the post. I'm trying to write a LINQ query (Linq to SQL) that will contain a multiple number of conditions in the where statement separa...

Quoting integers

I've been under the impression that quoting integers in SQL queries is frowned upon, but I've recently learned that prominent frameworks like Django adheres to this practice. Is it in fact perfectly acceptable? ...

Formatting a String for a SQL IN Clause

Hey Guys, I need to format a string and pass it in as parameter for a SQL IN clause such as: Select * from Table Where X In (@param1) The literal string that is passed in as a param looks like this: "Item1, Item2, Item3" This does not seem to work. Any suggestions? Thanks! ...

Value in db is a hyperlink, and wish to list based on the value of the hyperlink

Hi, I have made my parameter as a hyperlink. Now i want to click the hyperlink and then list of all information of that value in hyperlink. How do i do that? From Account No | To Acc No | Amount | Date So, from account no is value exist from db, and a hyperlink. so i wanna click from accno e.g (123456), and then it will list all tran...

Is there a downside to adding numerous indexes to tables?

I am creating a new DB and was wondering if there was any downside to adding numerous indexes to tables that I think may require one. If I create an index but end up not utilizing it will it cause any issues? ...

effect of number of projections on query performance

I am looking to improve the performance of a query which selects several columns from a table. was wondering if limiting the number of columns would have any effect on performance of the query. ...

How to move data between multiple database's table while maintaining foreign-key relationships/referential integrity?

I'm trying to figure out the best way to move/merge a couple tables of worth of data from multiple databases into one. I have a schema similar to the following: CREATE TABLE Products( ProductID int IDENTITY(1,1) NOT NULL, Name varchar(250) NOT NULL, Description varchar(1000) NOT NULL, ImageID int NULL ) CREATE TABLE ...

Should I use AI on these fields in MySQL?

I have this db below. I wonder how I should use the ID to identify each record. Everything is connected from the classified_table! Two Questions: Should I use AI on every PK in this case? Could somebody give me the FULL code for selecting an entire classified from only an ad_id ("bmw_330ci_8939483" for example)? I am new to normalize...

How to find the Value & Label field used in a query based parameter in sql reporting services?

In sql reporting services, I have a parameter on a report that is query based called InstitutionID. I have specified the Value field as InstitutionID and the Label field as InstitutionName based on a dataset. By using the reporting services API or by querying the ReportServer database directly I need to know which fields were used as t...

Do relational databases provide a feasible backend for a process historian?

In the process industry, lots of data is read, often at a high frequency, from several different data sources, such as NIR instruments as well as common instruments for pH, temperature, and pressure measurements. This data is often stored in a process historian, usually for a long time. Due to this, process historians have different req...

How do I exclude null rows without excluding null cells when pulling Excel into C# using SQL (ADO)?

I have a query like the following: SELECT * FROM OPENROWSET('MSDASQL', 'Driver={Microsoft Excel Driver (*.xls)};DBQ=D:\test.xls','SELECT * FROM Sheet1$]') This brings back rows that are all null if they were ever edited and then deleted. I want to exclude those, but still include rows that have good data but possible null cells. My ...

SQL If "something" select count

The output that comes from a custom view of mine is as follows... Col1 Col2 Col3 Col4 xxxx Cake 1 1* Cake xxxx 2* 1 xxxx Cake 2 0* xxxx Cake 0 0* Cake xxxx 2* 0 Cake xxxx 2* 0 and what i would like to sum is... For every row, if the word Cake is found in Col1, t...

Executing a VB.NET DLL From SQL Server

Objective: we want to write a DLL using VB.NET 2008 using .Net 3.5 that performs an HTTP request we then want to call the DLL From SQL Server 2005 (in a trigger) and pass the DLL some variables and get a return value. Where im at in the process. I have created the DLL 'HTTPDLL.dll' Source: Imports System Imports System.Configurati...

can we insert into two tables with single sql statement?

Will it be possible to insert into two tables with same insert command? ...

MySQL Find the total amount of posts per user

Hello I have a Database with the following two tables, USERS, POSTS I am looking for a way to get the count of how many posts a user has. Users Posts +----+------+ +----+---------+-----------+ | ID | Name | | ID | user_id | Name | +----+------+ +----+---------+-----------+ | 1 | Bob | | 1 | 1 | B...

SQLCMD, when called from Powershell, returns ExitCode == 1, even if successful

Hi everyone. I have a Powershell script that calls sqlcmd to run a sql script that backs up a database: function RunSqlScriptWithErrorMessage { param([string]$sqlServer, [string]$sqlUserName, [string]$sqlPassword, [string]$scriptName, [string]$errorMessage) $commandName = "sqlcmd" $startInfo = New-Object Diagnostics.Proces...

SQL. How to work/compare/find differences within different rows in the same table.

Hello, I have a table which looks like this: ID Date Size Marked 1 2010-02-02 2 X 2 2002-02-02 1 1 2010-02-03 2 X 2 2010-02-03 3 3 2010-02-03 4 X And I have a code (PHP) which does following things: a) Calculate sum of sizes per day b) Find the difference between tot...