Friday, March 23, 2012
How do I insert CR/LF - CHAR(13) does not work
Any suggestions how to insert CR/LF or why my installation is not responding to CHAR(13) is there some other escape code I could use?Char(10) ?|||An ASCII cr/lf is hexidecimal 0D0A. You could declare a char(2) variable and set it to 0x0D0A, then concatinate it to the string at your desired break points.
<code>
declare @.crlf char(2)
select @.crlf = 0x0D0A
</code>
HTH
Tom|||Hmmm, seems to work, my bad - I guess the results in QA are not accurate, but in the email the CR/LF exists.
Monday, March 12, 2012
how do i get date into dd-mm-yy format?
i have the following in an insert stored proc
CONVERT(CHAR(8),GETDATE(),10)
but this inserts 03-06-06.
how do i get it to 06-03-06?
Cheers,
Craig
my sp is as follows:-
IF (@.blnConsent = 1 AND @.dteActualConsentDate <> NULL) --This is PC insert for YES consent where a ConsentDate is supplied
BEGIN
INSERT INTO tblStudyServices
(SurveyID, PatientID, FourRegularDrugs, FourRegularDrugsNo, HRD,
ReadmissSixMonths, Consent, ConsentDate, CreationDate)
VALUES
(@.intSurveyID, @.intPatientID, @.blnFourRegularDrugs, @.intFourRegularDrugsNo, @.blnHRD,
@.blnReadmissSixMonths, @.blnConsent, @.dteActualConsentDate, CONVERT(CHAR(8),GETDATE(),10))
END
@.dteActualConsentDate is passed in as 14-03-06
if i then look in the table it has
CosentDate = 14-03-06
CreationDate = 03-06-06
i have tried SET_DATEFORMAT dmy
but still no luck
|||Datetime values are not stored in any special format. There are special allowed format and rules for inserting datetime. For output, it is the client application that formats the value to something that is human-readable. See http://www.karaszi.com/SQLServer/info_datetime.asp for more information. -- Tibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://www.solidqualitylearning.com/ Blog: http://solidqualitylearning.com/blogs/tibor/> CONVERT(CHAR(8),GETDATE(),10) >
> but this inserts 03-06-06. >
> how do i get it to 06-03-06? >
> Cheers,
> Craig >
>|||Did you see the reply I posted? -- Tibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://www.solidqualitylearning.com/ Blog: http://solidqualitylearning.com/blogs/tibor/
> my sp is as follows:- >
> IF (@.blnConsent = 1 AND @.dteActualConsentDate <> NULL) --This is PC
> insert for YES consent where a ConsentDate is supplied
> BEGIN
> INSERT INTO tblStudyServices
> (SurveyID, PatientID, FourRegularDrugs, FourRegularDrugsNo, HRD,
> ReadmissSixMonths, Consent, ConsentDate, CreationDate)
> VALUES
> (@.intSurveyID, @.intPatientID, @.blnFourRegularDrugs,
> @.intFourRegularDrugsNo, @.blnHRD,
> @.blnReadmissSixMonths, @.blnConsent, @.dteActualConsentDate,
> CONVERT(CHAR(8),GETDATE(),10))
> END >
> @.dteActualConsentDate is passed in as 14-03-06 >
> if i then look in the table it has >
> CosentDate = 14-03-06
> CreationDate = 03-06-06 >
> i have tried SET_DATEFORMAT dmy >
> but still no luck >
>