I have a large table (300 million lines) that I would like to dump to a csv - I need to do some processing that cannot be done with SQL. Right now I am using Squirrel as a client, and it does not apparently deal very well with large datasets - at least as far as I can tell from my own (limited) experience. If I run the query on the actual host, will it use less memory? Thanks for any help.
I have a table foo and a table bar, where each foo might have a bar (and a bar might belong to multiple foos).
Now I need to select all foos with a bar. My sql looks like this
SELECT * FROM foo f WHERE [...] AND ($param IS NULL OR
(SELECT ((COUNT(*))>0) FROM bar b WHERE f.bar = b.id))
with $param being replaced at runtime.
The question is: Will the subquery be executed even if param is null, or will the dbms optimize the subquery out?
This is probably easy, but eludes me.
SQL server2005
I want to show top 100 but if there are not 100 only want to show those and not include zero counts in the result
SELECT TOP (100) UserName, FullName_Company, FullName,
(SELECT COUNT(*)
FROM dbo.Member_Ref
WHERE (RefFrom_UserName = dbo.view_Members.UserName) AND (RefDate >= '5/1/2010') AND (RefDate <= '6/1/2010'))
AS RefFromCount
FROM dbo.view_Members
WHERE (MemberStatus = N'Active')
ORDER BY RefFromCount DESC
I have tried using Group By and HAVING COUNT(*)0 all with the same wrong results
I have a single MYSQL Question and need help ASAP.
Database:
Email | Name | Tag
[email protected] |Test Person | TagOne
[email protected] |Test Person | Tag Two
Need an SQL query that will return
Email | Name | Tag
[email protected] |Test Person | TagOne, Tag Two
Any help?
Hi,
I have a StreamReader object that I initialized with a stream, now I want to save this stream to disk (the stream may be a gif or jpg or pdf etc).
SO my code so far is:
StreamReader sr = new StreamReader(myOtherObject.InputStream);
I need to save this to disk (I have the filename).
In the future I may want to store this to sqlserver
I have the encoding type also, which I will need if I store it to sql server right?
I am using SQL Server 2000. I have a database with n number of tables in it. I have configured a maintenance plan. If I enable integrity check and run the plan, I am not able to enter any data through VC++/ADO.
Is there anything I have to check?
I want to query like this:
select * from table where concat(',', ServiceCodes, ',') like '%,33,%';
select * from table where (','||ServiceCodes||',') like '%,33,%';
so, I wrote this code:
ICriteria cri = NHibernateSessionReader.CreateCriteria(typeof(ConfigTemplateList));
cri.Add(Restrictions.Like(Projections.SqlFunction("concat", NHibernateUtil.String, Projections.Property("ServiceCodes")), "%,33,%"));
I get sql similar :
select * from table where (ServiceCodes) like '%,33,%';
But it is not what I want,how to do it???
thanks!
Is this how hashed password stored in mssql should look like?
This is function I use to hash password (I found it in some tutorial)
public string EncryptPassword(string password)
{
//we use codepage 1252 because that is what sql server uses
byte[] pwdBytes = Encoding.GetEncoding(1252).GetBytes(password);
byte[] hashBytes = System.Security.Cryptography.MD5.Create().ComputeHash(pwdBytes);
return Encoding.GetEncoding(1252).GetString(hashBytes);
}
Thanks,
Ile
MS SQL Server has a TABLE data type which can be used in stored procedures,
Does anybody know if MySQL has an equivalent data type?
I've had a look over the docs but can't seem to find anything, so I presume it doesn't exist, but perhaps somebody has created a workaround
i am trying to create a statement in sql (for a table which holds stock symbols and price on specified date) with avg of 5 day price and avg of 15 days price for each symbol.
table description:
symbol
open
high
close
date
the average price is calculated from last 5 days and last 15 days. i tried this for getting 1 symbol:
SELECT avg(close),
avg(`trd_qty`)
FROM (select *
from cashmarket
WHERE symbol = \'hdil\'
order by `M_day` desc
limit 0,15 ) s
...but I couldn't get the desired the list for showing avg values for all symbols.
Hi,
I have following SQL tables.
ImportantMessages
impID
Message
ImportantMessageUsers
imuID
imuUserID
imuImpID
I want to write a Linq2Sql query so that it returns any rows from ImportantMessages
that does not have a record in ImportantMessagesUsers.
Matchiing fields are
impID ----- imuImpID
Assume imuUserID of 6
What is the most standard encryption technique used in sql server for asp.net c# enterprise level application? . i am talking with respect to standards like md5 or sh1 etc, hashing
hi
please help i have a sharepoint site with sql connection i am able to view the info on the page but other sharepoint users in the company cant how can i add them on as users to my database? , my connection string on my page is as follows :
con = new SqlConnection("server=srvgmssapqas;database=hrportal2;Trusted_Connection=True");
I am using SQLite,
TABLE A
(
ID
FileNAME
FOLDERID
)
TABLE B
(
FOLDERID
FOLDERPATH
)
I want to write a sql statement to delete all files in A where its Folder is subfolder of C:\ABC\;
How Can I make it in one sqlite statement, and is it the best way to do?
Many thanks!
Hi,
have select like
select trn_dt,collect(ac_no) from transactions where rownum < 1000
group by trn_dt
i'm doing it in SQL Navigator. But i can't export results!
Table collect(ac_no) is not exported. Is there any way out?
I need to use C# to get data from database(sql) and the data in database is updated every few seconds. So do I have to make a loop or there is a better way to do that? Is it possible that when database is updating, the program can wait until it finishes updating? thx!
I am using linq to sql
Currently i am binding gridviw through linq which query written in business logic call .
i have extract record through query in business logic class and i want to bind that particular data to gridviw and return data .
how to retrun data which type is array.
code is mention below:
CMSBusiness.DataClasses1DataContext db = new DataClasses1DataContext();
var cate = from p in db.categoryTables
select new
{
categoryId=p.categoryId,
categoryName=p.categoryName,
categoryDesc=p.categoryDesc
};
how to return value and bind gridview , Please suggest
hello,
i am developing wpf application..
i need your suggestions.
i have to make reports in my application...
so which one is best, by crystal report or by using sql server reporting service..
friends what you say ? give ur suggestion which one is best and why ???
I had a table (Some_Table) with two columns:
A B
-------------------
1 test
2 test
3 test1
4 test1
i would like to return DISTINCT values for column B and it's associated value in column A (first in distinct set), so something like this:
A B
-----------
1 test
3 test1
What is the sql?
I am wondering how I can add DATA LINK form to my WIN application.
You know those forms where Users can choose on witch SQL server they going to connect
and what type of security they going to use and on wht database.
Something like on this picture
I'm doing a .NET unit as part of my studies. I've only just started, with a lecturer that as kinda failed to give me the most solid foundation with .NET, so excuse the noobishness.
I'm making a pretty simple and generic database-driven application. I'm using C# and I'm accessing a Microsoft Access 2007 database.
I've put the database-ish stuff in its own class with the methods just spitting out OleDbDataAdapters that I use for committing. I feed any methods which preform a query a DataSet object from the main program, which is where I'm keeping the data (multiple tables in the db).
I've made a very generic private method that I use to perform SQL SELECT queries and have some public methods wrapping that method to get products, orders.etc (it's a generic retail database).
The generic method uses a separate Connect method to actually make the connection, and it is as follows:
private static OleDbConnection Connect()
{
OleDbConnection conn = new OleDbConnection(
@"Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\Temp\db.accdb");
return conn;
}
The generic method is as follows:
private static OleDbDataAdapter GenericSelectQuery(
DataSet ds, string namedTable, String selectString)
{
OleDbCommand oleCommand = new OleDbCommand();
OleDbConnection conn = Connect();
oleCommand.CommandText = selectString;
oleCommand.Connection = conn;
oleCommand.CommandType = CommandType.Text;
OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter.SelectCommand = oleCommand;
adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
adapter.Fill(ds, namedTable);
return adapter;
}
The wrapper methods just pass along the DataSet that they received from the main program, the namedtable string is the name of the table in the dataset, and you pass in the query you wish to make.
It doesn't matter which query I give it (even something simple like SELECT * FROM TableName) I still get thrown an OleDbException, stating that there was en error with the FROM clause of the query. I've just resorted to building the queries with Access, but there's still no use. Obviously there's something wrong with my code, which wouldn't actually surprise me.
Here are some wrapper methods I'm using.
public static OleDbDataAdapter GetOrderLines(DataSet ds)
{
OleDbDataAdapter adapter = GenericSelectQuery(
ds, "orderlines", "SELECT OrderLine.* FROM OrderLine;");
return adapter;
}
They all look the same, it's just the SQL that changes.
I have a asp:GridView with a HyperLinkField. It's DataNavigateUrlFormatString property is set to View.aspx?id={0}&isTechnical={1}
Select command of appropriate SqlDataSource returns columns of type INT and BYTE (from SQL Server 2008).
So displayed string becomes something like View.aspx?id=1&isTechnical=1. But I want to display isTechnical=true|False, i.e. Convert.ToBoolean(row["isTechnical"]).ToString().ToLowerInvariant().
How to implement such conversion in page markup?