|
srinivasintouch wrote: The OLE DB provider "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Providers\OLEDB\Microsoft.Jet.OL
EDB.4.0" has not been registered.
Have you fixed this problem?
If you try to write that in English, I might be able to understand more than a fraction of it. - Guffa
|
|
|
|
|
Hello everyone,
In my C# program I load an XML file to a dataset. It has elements called "page". Three of its nodes are year, month and day.. I want to write a query that whenever a user gives two different dates, the query should select the "page"s which's date fall between the given dates.
How can I achieve this. I tried a lot but while I am a rookie I couldn't find a solution. Also google doesn't help.
Thanks for your helps and best regards.
.:: Something is Wrong ::.
|
|
|
|
|
SELECT * FROM MyTable WHERE DateColumn > @startDate AND DateColumn <@endDate
If that is not the answer you are looking for, then perhaps you could explain which part you are stuck on.
|
|
|
|
|
Well, the problem is thatI haven't got any DateColumn.. There are three columns named year, month and date..
Anyway, I have solved it. I wrote a query like this :
<br />
dateQuery = "((year > '" + date.Year.ToString() + "') AND (year < '" + date2.Year.ToString() + "')) "<br />
+ "OR ((year = '" + date.Year.ToString() + "') AND (month > '" + date.Month.ToString() + "')) " <br />
+ "OR ((year = '" + date.Year.ToString() + "') AND (month = '" + date.Month.ToString() + "') AND (day > '" + date.Day.ToString() + "')) "<br />
+ "OR ((year = '" + date2.Year.ToString() + "') AND (month < '" + date2.Month.ToString() + "')) " <br />
+ "OR ((year = '" + date2.Year.ToString() + "') AND (month = '" + date2.Month.ToString() + "') AND (day < '" + date2.Day.ToString() + "')) ";<br />
It seems a bit confusing, but it do the job
Thanks a lot for your helps..
.:: Something is Wrong ::.
|
|
|
|
|
I havent really gone thru your query. Why not just do something simpler, so that your query is more readable in the future or to someone who is seeing your code.
<br />
WHERE Convert(datetime,day + '/' + month + '/' + year,103) >= '"+ date.ToString() +"' AND <br />
Convert(datetime,day + '/' + month + '/' + year,103) < '"+ date2.ToString() +"' .......<br />
Just an example, you may have to rewrite the query to your need.
Tarakeshwar Reddy
MCP, CCIE Q(R&S)
Experience is like a comb that life gives you when you are bald - Navjot Singh Sidhu
|
|
|
|
|
That is a better solution - but still potentially suscepatable to a SQL Injection Attack. Consider the use of parameters rather than injecting values into the string.
|
|
|
|
|
Colin Angus Mackay wrote: Consider the use of parameters
And of course, read your article on SQL Injection Attacks
Some people have a memory and an attention span, you should try them out one day. - Jeremy Falcon
|
|
|
|
|
when i m trying to connect my c# application with Sql Server then a message is coming as"SQLNCLI.1" provider is not registered on the local machine. Any solution
sincerly
shriya
|
|
|
|
|
Do you have native client (client tools) installed on your local machine?
|
|
|
|
|
Hello,
I am using a report that has 2 subreports and when I create a 3rd it does not display any data on the form where they should be in the other 2 subreports.
My code is below.
I if take 1 subreport off and leave the other 2 then the report will display the data. but if i add another one then it displays nothing in the other 2 subreports.
I have used typed dataset. I don't have any groups, and deleted the links in the database expert of the report.
<br />
report.Load(Application.StartupPath & "/rptJobSheet5.rpt")<br />
<br />
report.SetDataSource(DS_JobSheet2)<br />
report.Subreports.Item(0).SetDataSource(DS_JobSheet2.Tables("IncidentTask"))<br />
report.Subreports.Item(1).SetDataSource(DS_JobSheet2.Tables("Supportcontracts"))<br />
report.Subreports.Item(2).SetDataSource(DS_JobSheet2.Tables("Client"))<br />
<br />
Me.CrystalReportViewer1.ReportSource = report<br />
Another quick question:
item(0) what name would this be in the properties of the subreport. I create the subreport using the wizard and have called it Client. but if i do this item("client") it shows an error. Also I have tried changing the name to this in the subreport properites | name. Should I use the index of the name property.
Thanks in advance,
Steve
|
|
|
|
|
Hello,
Is there anyway to append some value to colunm name? For example, i have table with 150 colunms and i want to do Select * and append today's date with each colunm name. So column1, column2... should display colunm1_112006, column2_112006 and so on etc. I'll appreciate any help.
Thanks in advance.
|
|
|
|
|
"select column1 as column1_112006,colum2 as column2_112006 from table1"
|
|
|
|
|
I don't want to use keyword "as" for 150 columns. Is there any way to rename using "select *" ?
|
|
|
|
|
Nope.
You could build your query dynamically in a stored procedure (Use schema to get the column names).
150 column table doesn't sound like a good design...
|
|
|
|
|
Rob Graham wrote: 150 column table doesn't sound like a good design...
Normalization could be a good idea
Some people have a memory and an attention span, you should try them out one day. - Jeremy Falcon
|
|
|
|
|
Hi... looking for some insight here...
Another site has a SQLServer 2000 database that huge... There data collection mechanism has been modified and the growth rate is now severely reduced, but, in the mean time, I still have to delete approximately 3/4 of the data.
The process has been started, but, over the weekend, the database added another extent (20%). There is concern that the deletion process is causing the database to grow.
To date, I have deleted approximately 1 1/2 % of the data.
My questions are:
what happens to the deleted space? is it automatically reused?
what effect will a shrink have on the datbase?
Ultimately, we will delete no longer needed data, archive to another database anything over 2 years old and reindex the entire database, but, that is still a long way off.
Any ideas? If possible, links to reference material would be helpful.
And, I am not the DBA, just the person tasked with the cleanup.
Thanks,
Tim
|
|
|
|
|
Tim Carmichael wrote: I still have to delete approximately 3/4 of the data.
Wouldn't it make more sense to copy the 25% you want to keep to a new database, then drop the old database?
Tim Carmichael wrote: , over the weekend, the database added another extent (20%). There is concern that the deletion process is causing the database to grow.
Does the data you are removing reside in tables with clustered indexes? If so, is the order in which you are deleting the old date likely to free whole pages in such a way that new data can recycle the pages, or will new pages still be required to maintain physical page order of the clustered index?
|
|
|
|
|
Rob Graham wrote: Wouldn't it make more sense to copy the 25% you want to keep to a new database, then drop the old database?
If I had that option, it would be wonderful, however, this is a 24/7 production environment and I cannot recreate and move the data.
There are both clustered and unclustered indexes on the tables.
|
|
|
|
|
Tim Carmichael wrote: s is a 24/7 production environment and I cannot recreate and move the data.
But you can afford to let the database grow by 20% increments? which suggests that disk space is not a problem... Could you not select the data you wish to keep into a new table (in reasonable chunks to keep the transaction log manageable, and when you reach the last chunk, rename both old an new tables in the same transction (so new data starts going to the new table). Next just drop the old table and then shrink the database.
As others have mentioned allowing % based growth is very bad, particularly large percentages of large databases - the growth step is a very resource consuming operation. It is better to run big dbs like this at a fixed size (no growth), and run a free space monitor / purge routine on a regular basis (frequently enough to reclaim space before it can fill up by deleting or moving data).
|
|
|
|
|
Rob Graham wrote: But you can afford to let the database grow by 20% increments?
No, they can't afford to let it grow at that rate; the data is being collected too frequently and steps are being taken to address that. By the time we were involved in the process, the problem was already of gargantuan size... we are just trying to effect a solution.
Rob Graham wrote: It is better to run big dbs like this at a fixed size (no growth), and run a free space monitor / purge routine on a regular bas
Eventually, we will get to the point that we are keeping a rolling two years worth of production data in the database and the rest in an archive database, but, again, that is... eventually. How do you eat an elephant? One bite at a time... Right now, I am trying to take small bites and keep my data deletes ahead of the data additions, thereby effectively stopping the growth, but, that takes time.
|
|
|
|
|
BTW, Sql BOL (SQL Server 2000) says that an extent is only 8 8KB pages (a little less than 64KB data, given overhead). Unless you are using the 64bit edition (which might have larger extents, I don't know), 64KB is not really that much growth and if that represents 20% of your database, then you have a relatively small (320KB?) database...
Perhaps what you meant is that the database was configured to allow growth, and the allowed increment is 20%. In that case, if you were borderline near the next growth increment, even one more page of data could have forced the 20% step.
|
|
|
|
|
We are using the 32bit version, but the production database is currently at about 115Gig. The table is question has about 850,000,000 rows.
So, with a 20% growth overnight on the test instance of the database, the size increased from 98Gig to 115Gig.
Well... we soldier on...
|
|
|
|
|
Part of the problem here is that you should never, and I repeat NEVER, use a percentage for growth. This is a really bad thing to do, as you are finding out now.
What you need to do is to grow the database by a fixed amount.
Now, part of your problem sounds like it could well be the transaction logs. You may need to truncate your transaction logs as well because the delete will be writing to the log. Once you have truncated your logs, you can shrink the database and reclaim lost space.
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
|
Hi, Careful! Long read. Im SORRY!
SENARIO:
I have a senario where there are 3 related tables. One is called Request , the other Quote , and the last is called QuoteRequest .
Each quote can have many requests in it.
Each request can belong to more than one quote.
When I want to save a Quote record, I select several Requests from a Datagrid using checkboxes. Those requests will be assigned to that quote .
The Requests which are visible in that datagrid for selection, are the ones which have NOT been Quoted before.
Here's the problem!
Let's say a request has been quoted . The TimeEstimate of the request is 5 days. Then someone changes that TimeEstimate to 9 days. This means that 4 days are still unquoted!
There is one thing I MUST do before I can display those unquoted days back on the data grid. I MUST store the initial TimeEstimate of ANY quoted request in the QuoteRequest Table. This table will keep a track of all the requests which have been quoted. For instance it may have the following entries:
ID----RequestID----QuoteID----NoOfDaysEstimated<br />
1--------1-----------1---------------5---------<br />
2--------1-----------2---------------4---------
QUESTION:
What I want to do is simply this:
I want to STORE the TimeEstimate FROM the Request table INTO the QuoteRequest Table WHENEVER the AddQUOTE Stored Procedure is executed. This will effectively be populating the QuoteRequest Table with records of all the Requests which have been Quoted, and hence will allow me to display this info in a datagrid.
I don't know how to go about doing that.
If you do go through this, I thank you. If you can suggest something, I will be forever grateful.
|
|
|
|