Viewing 15 posts - 31 through 45 (of 53 total)
As Koen mentioned that is not possible in SQL and should explore the options he mentioned.
Probably one more option if i understand your question correctly is to do a LEFT...
February 19, 2014 at 6:53 am
Try the below code...
DECLARE @TransactionComponents TABLE
(
pkTransactionComponent int IDENTITY(1,1) NOT NULL,
pkTransactionID int NOT NULL,
ComponentID int NULL
)
INSERT INTO @TransactionComponents(pkTransactionID, ComponentID)
SELECT 1,5
UNION SELECT 1,6
UNION SELECT 1,7
UNION SELECT 1,8
UNION SELECT 1,9
UNION SELECT 1,10
UNION SELECT...
February 17, 2014 at 7:51 am
Duplicate post. Original thread available here
February 13, 2014 at 9:44 am
Try below
ALTER PROCEDURE [dbo].[..._count]
@StartDate datetime,
@EndDate datetime,
@Costcenter varchar(3),
@DiagnosisType varchar(100)
AS
SELECT .....
--where (dbo.ClinicalType.Code in (@DiagnosisType))
where CHARINDEX(LTRIM(RTRIM(dbo.ClinicalType.Code)),@DiagnosisType) > 0
February 13, 2014 at 9:41 am
DECLARE @MailBody VARCHAR(500)
SELECT @MailBody = 'My text for server ' + @@SERVERNAME
EXEC MSDB..SP_Send_DBMail
@Subject = 'my_subject',
@Recipients = 'my_email_adresse',
@Body = @MailBody,
@Profile_name = 'my_profile'
February 13, 2014 at 4:58 am
DECLARE @BetTime DATETIME
SELECT @BetTime = CONVERT(DATETIME,'03:30:00')
;WITH ShiftTimes AS
(
SELECT 1 AS ShiftNo,CONVERT(DATETIME,'06:00:00') AS StartTime,
CONVERT(DATETIME,'14:00:00') AS EndTime
UNION
SELECT 2,CONVERT(DATETIME,'14:00:00'),CONVERT(DATETIME,'22:00:00')
UNION
SELECT 3,CONVERT(DATETIME,'22:00:00'),CONVERT(DATETIME,'06:00:00')
)
SELECT TOP 1 * FROM ShiftTimes
WHERE EndTime >= @BetTime
ORDER BY EndTime
February 5, 2014 at 4:43 am
If the data is always numbers then just convert the data-type to integer which will remove the leading zero's.
SELECT CONVERT(INT,SUBSTRING(Oddvalue,1,charindex(' ',Oddvalue+' ',1)))
FROM @OddRows
February 4, 2014 at 9:17 am
Without the CASE statement
DECLARE @OddRows TABLE
(
Oddvalue VARCHAR(50)
)
DECLARE @PerfectRows TABLE
(
Oddvalue VARCHAR(50)
)
INSERT INTO @OddRows
SELECT '002849617 00009' UNION ALL
SELECT '002960330 00009' UNION ALL
SELECT '003181242 00009' UNION ALL
SELECT '003701140 00009' UNION ALL
SELECT '003789064 00009'...
February 4, 2014 at 9:10 am
This might not be the most elegant way but give it a try
SELECT StartDate =
CASE WHEN CONVERT(VARCHAR(8),@Trandate,112)
BETWEEN CONVERT(VARCHAR,YEAR(@Trandate)) + '0406'
AND CONVERT(VARCHAR,YEAR(@Trandate)+1) + '0405'
THEN CONVERT(DATETIME,CONVERT(VARCHAR,YEAR(@Trandate)) + '0406')
WHEN CONVERT(VARCHAR(8),@Trandate,112)
BETWEEN CONVERT(VARCHAR,YEAR(@Trandate)-1) +...
February 4, 2014 at 2:55 am
Something like this...
Col1 : SUBSTRING(@[User::Test],1,FINDSTRING(@[User::Test],".",1) -1)
Col2 : SUBSTRING(@[User::Test],FINDSTRING(@[User::Test],".",1) +1,LEN(@[User::Test]))
January 29, 2014 at 9:51 am
Hope this helps. You might want to refer this article
;WITH CTE AS
(
SELECT DISTINCT Header FROM Table_1
)
SELECT CONVERT(VARCHAR(MAX),Header + CHAR(10) +
STUFF((
SELECT CHAR(10) + Citation
FROM Table_1
WHERE Header = CTE.Header
ORDER BY id
FOR XML...
January 28, 2014 at 8:24 am
Try this
DECLARE @XML AS XML, @hDoc AS INT
SET @XML =
'<Root>
<WPID>4</WPID>
<WPName>??92</WPName>
<Sum>0</Sum>
<Result>03:30 , 18</Result>
<Count>1</Count>
</Root>'
EXEC sp_xml_preparedocument @hDoc OUTPUT, @XML
SELECT WPID, WPName, Sum, Result, Count
FROM OPENXML(@hDoc, 'Root')
WITH
(
WPID int 'WPID',
WPName [varchar](100) 'WPName',
Sum float 'Sum',
Result...
January 20, 2014 at 6:24 am
A csv file cannot have multiple sheets - you can open a csv file in excel and add sheets to it but then you have to save as an excel...
January 15, 2014 at 3:03 am
Package variables are case-sensitive, can you check in the agent job while setting the values for the variables, the variable names are same as defined within the package.
January 7, 2014 at 9:51 am
CHECKSUM & BINARY_CHECKSUM cannot accept text, ntext, image, cursor, xml, and noncomparable common language runtime (CLR) user-defined types. Try converting the XML data-type to VARCHAR.
With New_CodeXML as (
Select
binary_checksum(convert(varchar(max),new.PracticeOfficeXML)) as...
January 6, 2014 at 8:30 am
Viewing 15 posts - 31 through 45 (of 53 total)