|
Perhaps you actually think of a function for converting from/to Persian calendar?
|
|
|
|
|
yeah i think about it and i dont know how i can use this.
|
|
|
|
|
Seems to be a solved problem, have some google foo[^]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I ran this in the Management Studio:
update [Master] set Data_Thru = '7/23/2014 9:49:00 AM'
where Data_Thru = '7/23/2014 8:00:00 AM'
So why did it actually set the smalldatetime to 7/23/2014 9:50:00 AM?
(And don't yell at me for the table name. It wasn't my idea.)
|
|
|
|
|
Are you absolutely sure that that's the precise query that you executed, and that the row you're looking at is the one it updated?
smalldatetime[^] will round to the nearest minute, but it will only round up if the seconds are greater than or equal to 29.999; anything else will round down.
SELECT
CAST('7/23/2014 9:49:29.998 AM' as smalldatetime),
CAST('7/23/2014 9:49:29.999 AM' as smalldatetime)
;
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: Are you absolutely sure that that's the precise query that you executed, and
that the row you're looking at is the one it updated?
Yep.
Freaked me out. I've never seen that before, and it had no problem with me going in and correcting it back down to 9:49 via T-Sql
|
|
|
|
|
Weird. Are there any triggers on that table? Or other users updating the same row at the same time?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Nope. No triggers. And no users at all (yet).
Maybe we'll have to pass it off as a cosmic ray hitting the server and flipping a bit at just the right time. I see no resason for it, and Google came up with nothing, either.
|
|
|
|
|
When I run into impossible situations in code then the only solution is to examine my assumptions. That is always where I find the problem that lead to the impossibility in the first place.
|
|
|
|
|
What's the version / localization of your SQL Server?
I tried it with SQL Server 10.0.5500, German localized Management studio. I adjusted the date format of your query, and tested it. And it worked as it was expected to work - I cannot reproduce your bug.
|
|
|
|
|
10.50.1617.0 Management studio hitting 2008 R2 10.0.5500.0
I think it was a one-time glitch. I hate those.
|
|
|
|
|
Hi,
I have first_name, middle_name and last_name in my customers table.
I want to do
SELECT CONCAT(first_name, ' ', middle_name, ' ', last_name)
The middle name is optional
so I want to ignore it if it's blank to be:
SELECT CONCAT(first_name, ' ', last_name)
because if I do it the normal way I'll have extra space between the first_name and last_name
Technology News @ www.JassimRahma.com
|
|
|
|
|
You can use ISNULL on the first middle name or a case statement.
Case statement is more robust as it caters for ''.
Never underestimate the power of human stupidity
RAH
modified 20-Jul-14 22:36pm.
|
|
|
|
|
As long as you're doing it that way, you might as well use REPLACE.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
Without using CONCAT you can do this:
rtrim(isnull(first_name,'',first_name+' ') + isnull(middle_name,'',middle_name+' ') + isnull(last_name,'',last_name))
The rtrim will remove a trailing space where the person does not have a last name.
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
Hi i have created one web application and in that i need to read the data from Mysql database and bind to gridview.
I have written Mysql query as follows
SELECT @row_number:=@row_number+1 AS row_number,Name FROM tablename, (SELECT @row_number:=0) AS r
After running in Mysql in database it will and work show the result.
But if take same query and execute through C# code below error is coming.
An exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll but was not handled in user code
Additional information: Fatal error encountered during command execution.
and i will get Break or continue pop up. If i give continue it will show Parameter '@row_number' must be defined.
even i defined like int @row_number = 0; but same error.
I need to achieve serial number as shown below
ex in database
slno name
10102 nama1
2123 name2
5203 name3
result
1 nama1
2 name2
3 name3
how to achieve this. If anybody knows please reply me.
Thanks in advance.
|
|
|
|
|
This error occurs frequently and no insert query is running.
if i restart the sql server services it is working fine,but often getting this error message.
Recently i changed my management studio to 2012 as my server is 2008 R2 version.How to fix this issue permanently?
|
|
|
|
|
Hi,
Usually it's because there are corruption problems related to the storage system. Have you tried running DBCC CHECKDB against the database?
DBCC CHECKDB ('Your DB Name') WITH NO_INFOMSGS;
GO
This could give you more information.
Also, check the Auto Close property:
SELECT DATABASEPROPERTY ('Your DB Name', 'IsAutoClose');
GO
If it returns 1 (Auto Close is on), then that may be the reason of your problem...
Regards,
Andrius Leonavicius
|
|
|
|
|
Dear Sir,
It shows the following error
Msg 1823, Level 16, State 2, Line 1
A database snapshot cannot be created because it failed to start.
Msg 7928, Level 16, State 1, Line 1
The database snapshot for online checks could not be created.
Either the reason is given in a previous error or one of the underlying volumes
does not support sparse files or alternate streams. Attempting to get exclusive
access to run checks offline.
my database shows is_auto_close_on=1.
What i should do to solve this?
|
|
|
|
|
I'd recommend to turn off the Auto Close:
ALTER DATABASE database_name
SET AUTO_CLOSE OFF;
GO
Speaking about errors, try to restart the server and run DBCC CHECKDB again. Also, take a look at Windows Event Logs for errors.
BTW, do you have enough disk space?
Regards,
Andrius Leonavicius
|
|
|
|
|
The Log For the Database is Not Available[^]
And please, do not post your question all over the place...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
hi , i have two table first table name is person and second table name is payment
what i'd like to do is that , i want to select those persons who haven't paid they'r bill for two month
select person.* from (person INNER JOIN
payment ON person.national_number = payment.national_number)
where (payment.payment_date > 'two month ago from now')
but this w'll fetch those persons who paid their bill for the two month ( i don't want them) . but i need those who didn't pay they'r bill for the two month
i don't know if you understand it or no .
|
|
|
|
|
Surely
where (payment.payment_date < 'two month ago from now')
?
|
|
|
|
|
Assuming that one person can have multiple payments, an INNER JOIN will return a record for every payment over two months old, regardless of whether the person has paid within the last two months.
What you need to do is find the person records which don't have a payment record within the last two months. To do that, you can use a Not Exists filter:
DECLARE @Today date = GetUtcDate();
DECLARE @CutoffDate date = DateAdd(month, -2, @Today);
SELECT
*
FROM
person
WHERE
Not Exists
(
SELECT 1
FROM payment
WHERE payment.national_number = person.national_number
And payment.payment_date > @CutoffDate
)
;
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Won't that have to look up each national_number in payment separately? It always looks like it does. I don't use EXIST.
You'll never get very far if all you do is follow instructions.
|
|
|
|