Showing posts with label case. Show all posts
Showing posts with label case. Show all posts

Thursday, March 29, 2012

DB Backup - Single User Mode

Tx for your responses.
I completely understand and accept that there is no need to do a
backup in single user mode, but for one case if the server is already
in single user mode ..
Here is what I found, in SQL 2000 it was possible to do the
backups(in single user mode) while the SQL 2005 server fails to accept
the connection for backup (the same code/binary SQL-DMO statements are
used for both).
Are there any major changes between SQL server 2000 and SQL server
2005 ?
On Oct 31, 3:02 am, "Tibor Karaszi"
<tibor_please.no.email_kara...@.hotmail.nomail.com> wrote:[vbcol=seagreen]
> If you mean regular backups (usingBACKUPDATABASE andBACKUPLOG commands), then no, no need to set
> the database tosingleusermode...
> --
> Tibor Karaszi,SQLServer MVPhttp://www.karaszi.com/sqlserver/default.asphttp://sqlblog.com/blogs/tibor_karaszi
> "velu5" <thirumalaiv...@.gmail.com> wrote in message
> news:1193743910.012534.3610@.v29g2000prd.googlegrou ps.com...
>
What's New in SQL Server 2005:
http://www.microsoft.com/sql/prodinfo/overview/whats-new-in-sqlserver2005.mspx
http://technet.microsoft.com/tr-tr/library/ms170363(en-us).aspx
Ekrem nsoy
"velu5" <thirumalaivelu@.gmail.com> wrote in message
news:eb680ec9-d7c5-40c2-bec6-bbbdeada23af@.e23g2000prf.googlegroups.com...
> Tx for your responses.
> I completely understand and accept that there is no need to do a
> backup in single user mode, but for one case if the server is already
> in single user mode ..
> Here is what I found, in SQL 2000 it was possible to do the
> backups(in single user mode) while the SQL 2005 server fails to accept
> the connection for backup (the same code/binary SQL-DMO statements are
> used for both).
> Are there any major changes between SQL server 2000 and SQL server
> 2005 ?
>
> On Oct 31, 3:02 am, "Tibor Karaszi"
> <tibor_please.no.email_kara...@.hotmail.nomail.com> wrote:
>

Monday, March 19, 2012

DateTime help

I am having issues with Two lines in my Stored Procedure:

'426.Ins1EffectiveDate'=CASE WHEN ISNULL(CONVERT(VARCHAR,pi.InsCardEffectiveDate,101),'')IS NULL THEN '' ELSE CAST(pi.InsCardEffectiveDate AS varchar)END,
'427.Ins1TerminationDate'= CASE WHEN ISNULL(CONVERT(VARCHAR,pi.InsCardTerminationDate,101),'')IS NULL THEN '' ELSE CAST(pi.InsCardTerminationDate AS varchar)END

Its returning a date value as such:

Mar 12 2008 12:00AM

I dont want the 12:00 AM ... in fact, I want it to read 03/12/2008

Give a look to the CAST AND CONVERT article in books online. You ought to be able to change the ",101" date format specification to fix this problem.

Maybe try converting this:

Code Snippet

'426.Ins1EffectiveDate'=CASE WHEN ISNULL(CONVERT(VARCHAR,pi.InsCardEffectiveDate,101),'')IS NULL THEN '' ELSE CAST(pi.InsCardEffectiveDate AS varchar)END,
'427.Ins1TerminationDate'= CASE WHEN ISNULL(CONVERT(VARCHAR,pi.InsCardTerminationDate,101),'')IS NULL THEN '' ELSE CAST(pi.InsCardTerminationDate AS varchar)END

into this:

Code Snippet

'426.Ins1EffectiveDate'=CASE WHEN ISNULL(CONVERT(VARCHAR,pi.InsCardEffectiveDate,101),'')IS NULL THEN '' ELSE convert(varchar,pi.InsCardEffectiveDate,101)END,
'427.Ins1TerminationDate'= CASE WHEN ISNULL(CONVERT(VARCHAR,pi.InsCardTerminationDate,101),'')IS NULL THEN '' ELSE convert(varchar,pi.InsCardTerminationDate,101)END

After you try this, check back because it looks like you have another logic problem. Something along the lines of this:

Code Snippet

'426.Ins1EffectiveDate'=CASE when pi.InsCardEffectiveDate IS NULL THEN '' ELSE convert(varchar,pi.InsCardEffectiveDate,101)END,
'427.Ins1TerminationDate'= CASE WHEN pi.InsCardTerminationDate IS NULL THEN '' ELSE convert(varchar,pi.InsCardTerminationDate,101)END

might be more appropriate

|||

It seems you are making this overly complicated. (Unless I'm missing something...)

I don't think that you need to use the CASE structure...

JeffS2002 wrote:


'426.Ins1EffectiveDate'=CASE WHEN ISNULL(CONVERT(VARCHAR,pi.InsCardEffectiveDate,101),'')IS NULL THEN '' ELSE CAST(pi.InsCardEffectiveDate AS varchar)END,
'427.Ins1TerminationDate'= CASE WHEN ISNULL(CONVERT(VARCHAR,pi.InsCardTerminationDate,101),'')IS NULL THEN '' ELSE CAST(pi.InsCardTerminationDate AS varchar)END

Perhaps something more like this:

'426.Ins1EffectiveDate' = isnull( convert( varchar(10), pi.InsCardEffectiveDate, 101 ), '' )

Follow this example:

Code Snippet


DECLARE
@.InsCardEffectiveDate datetime,
@.NullDate datetime


SET @.InsCardEffectiveDate = '20070711'


SELECT
NullDate = isnull(( convert( varchar(10), @.NULLDate, 101 )), '' ),
InsCardEffectiveDate = isnull(( convert( varchar(10), @.InsCardEffectiveDate, 101 )), '' )

NullDate InsCardEffectiveDate
- --
07/11/2007

Saturday, February 25, 2012

DateSerial in Access to SQL

Hi,
I need to convert this Access code to a Sql Case statement, but I'm not sure
exactly how...
IIf([Conversion Detail Table]!TXTDT<>0,DateSerial((Int(Left([Conversion
Detail Table]!TXTDT,4))),(Int(Mid([Conversion Detail
Table]!TXTDT,5,2))),(Int(Right([Conversi
on Detail
Table]!TXTDT,2)))),#10/1/2004#)
Can anyone help, thank you very much!
PatriceTry,
select
case when rtrim(TXTDT) != '0' then cast(left(8, TXTDT) as datetime) else
cast('20041001' as datetime) end
from
[Conversion Detail Table]
go
AMB
"Patrice" wrote:

> Hi,
> I need to convert this Access code to a Sql Case statement, but I'm not su
re
> exactly how...
>
> IIf([Conversion Detail Table]!TXTDT<>0,DateSerial((Int(Left([Conversion
> Detail Table]!TXTDT,4))),(Int(Mid([Conversion Detail
> Table]!TXTDT,5,2))),(Int(Right([Conversi
on Detail
> Table]!TXTDT,2)))),#10/1/2004#)
> Can anyone help, thank you very much!
> Patrice
>