|
Do some research on DATEADD (datepart , number, date ) function.
Always remember:
Without efforts nothing great is ever achieved.
Parwej Ahamad
R & D: REST services with WCF
|
|
|
|
|
Hi i need between two dates what are the working days are there like...,
In 2nd and 4th saturday workdays=5
and odd saturday workdays=6
Suppose if i give 7/2/2008 to 7/26/2008...,
Then I want these dates:
7/2/2008
7/3/2008
7/4/2008
7/5/2008
7/7/2008
7/8/2008
7/9/2008
7/10/2008
7/11/2008
7/14/2008
7/15/2008
7/16/2008
7/17/2008
7/18/2008
7/19/2008
7/18/2008
7/21/2008
7/22/2008
7/23/2008
7/24/2008
7/25/2008
7/26/2008
Any one plz help me regarding this...........,
Thanks & Regards,
NeW OnE,
please don't forget to vote on the post
|
|
|
|
|
Again, post what you have tried.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi,
Anyone could provide me solution. I have table like this
Date | Status
--------------------------------
12/07/08 | 2
12/07/08 | 3
12/07/08 | 3
13/07/08 | 2
13/07/08 | 3
13/07/08 | 2
----------------------------------
I want count of status on each day. For Clear understanding output should like this
Date | Total 2 | Total 3
---------------------------------
12/07/08 | 1 | 2
13/07/08 | 2 | 1
----------------------------------
Thanks
Binod K.
(Miles to go before I sleep)
|
|
|
|
|
This is what you need, BUT ... next time, post some code that you tried here so we know that we are not doing all your job
SELECT
Date
, [2] AS [Total 2]
, [3] AS [Total 3]
FROM YOUR_TABLE_NAME
PIVOT (
COUNT( Status )
FOR Status IN ( [2] , [3] )
) AS p
|
|
|
|
|
select distinct [date],<br />
(select count(t1.status) from MyTable as t1 where status=2 and t1.date=MyTable.[date]) as [Total 2],<br />
(select count(t1.status) from MyTable as t1 where status=3 and t1.date=MyTable.[date]) as [Total 3]<br />
from MyTable
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
|
|
|
|
|
hi
my data field is integer i give a query like this
select * from news where newsid like '123%'
it display error
i want to display news where my newsid is start with 123
please help me
|
|
|
|
|
There is nothing wrong with the code you posted ... what error do you get?
|
|
|
|
|
Yes there is the like operator is not valid agains a numeric or date field. Note the field is an integer. Either turn it into a varchar or use numeric operators
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You need to cast your newsid to varchar.
|
|
|
|
|
I was thinking the same thing, but like implicitly coverts int's to varchar. I think it would help a lot if we knew what the error is instead of guessing.
|
|
|
|
|
Scott Clewell wrote: but like implicitly coverts int's to varchar
Ok - I was not aware of that, it still feels like he is attempting the wrong thing, I would never rely on an implicit conversion there is a cost in the implicit conversion that I find unacceptable and the bloody thing will bite you sometime in the future.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
i got it why you got this error!!!
You cannot use a Like wild card with Integers .. is ur newsid is int?
Cheers,
ZAK
|
|
|
|
|
Hi i am having table like this:
Name Dates
N1 7-21-2008
N1 7-24-2008
N2 7-21-2008
N2 7-27-2008
N3 7-24-2008
Now i want o/p like this:
Name Dates
N1 7-21-2008,7-24-2008
N2 7-21-2008,7-27-2008
N3 7-24-2008
Thanks & Regards,
NeW OnE,
please don't forget to vote on the post
|
|
|
|
|
Well, what do YOU think the sql should be? Have a try, post your sql and then someone may help you.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Ashfield wrote: Have a try, post your sql and then someone may help you
Thank you. OP was beginning to sound like an annoying mooch who wants someone to do their work for them.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Exactly.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Beginning to?
Sounded like it from post number 2.
|
|
|
|
|
Not just the past two or so, but the OP was going on about the same thing the other day. Did get some replies. It just goes to show how true it is with my sig from John Simmons
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi everybody,
I made a primitive cost control database system using Microsoft Access 2007 as a front-end (don't ask my why did I use Microsoft Access!!!) and SQL Server 2005 Enterprise as a back-end
This program depends on regrouping data, so I have sections and each section in front of it has the total of it's item
Everything is working smoothly, except that the last line in any list, which is empty, gives me #Error in calculated controls
What should I do to avoid that?
Thank you... 
|
|
|
|
|
Hi! I have such problem: when my web application make a request to
MS SQL Server 2005, and the last one have to send back a lots of data, it's throwing an error:
"An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
SqlException
"
But on all other cases, it works well. It's very strange I think. Have you any ideas?
|
|
|
|
|
Hi,
The first thing that comes in mind is timeout. What is your operation timeout defined in connection and how long the data retrieval is taking (until you get the error).
Another thing is your connection pool. Sure that the connection isn't aging out?
Few additional questions:
- is the request a select statement or procedure call
- check the state of the connection before executing the command. Is it open?
- does the error occur immediately or when some time has elapsed
- what about database server side? Do you see the open connection
- are you able to trace the statement execution at server side
Mika
|
|
|
|
|
Timeout is set to default, it's not defined in connection string. About connection pool - I don't know, I haven't direct access to this server for now.
Answer your questions:
- Request is a select statement
- I'm using linq database context
- error occurs after 10 -50 seconds.
- no, I don't
- no I'm not
This error occurs with 80% frequency, not always.
Thanks.
|
|
|
|
|
Hmm,
What you could try is (modify only one thing at once and if nothing is changed, return to original configuration):
- add connection timeout-parameter to connection string ("Connection Timeout=60 ") The default id 15 seconds.
If the server is running low on resources, it may be unable to give you a connection in 15 seconds.
- increase packet size by adding "Packet Size=16384 ". Default is 8192.
This way the server doesn't need to send so many packets especially when large amount of data is to be sended
- Try disabling connection pooling by adding "Pooling=false " to your connection string. Default is true.
This will eliminate possible aging problems in pool
if possible at database server side you should check:
- start the query and check in database, how your connection is doing.
This can be done by using Management studio or sp_who stored procedure. You should see your connection in "runnable" state
- check the error logs for sql server. When the query is returning you an error, is anything recorded in error log
And of course you could try to run the select statement using 'normal' SqlCommand class along with data reader without LINQ. Just to make sure that LINQ isn't causing any problems.
I'm sorry that I cannot be more specific, but the problem isn't the easiest one to solve.
If you find out anything, please post your findings
Mika
|
|
|
|
|
Thanks,I'll try 
|
|
|
|