Viewing 15 posts - 31 through 45 (of 89 total)
SELECT T1.StudentID,StudentName, StudentAge,ColX,Coly,
MAX(CASE WHEN Subject = 'English' THEN 'English' ELSE '' END) AS Subject1,
MAX(CASE WHEN Subject = 'English' THEN Marks ELSE 0 END) AS Marks1,
MAX(CASE WHEN Subject = 'English'...
December 24, 2013 at 8:01 am
DECLARE @Employees TABLE (EmployeeId INT, LocationId INT, ActualStartDate DATETIME, ActualEndDate DATETIME)
INSERT @Employees
SELECT 20347,44,'2013-11-04 10:50:41.463','2013-11-04 10:53:03.953'
UNION ALL
SELECT 20347,44,'2013-11-06 13:39:03.733','2013-11-06 13:43:00.863'
UNION ALL
SELECT 20347,44,'2013-11-06 14:42:03.697','2013-11-06 14:46:00.863'
UNION ALL
SELECT 23658,80,'2013-11-01 11:18:08.767','2013-11-01 11:26:45.523'
UNION ALL
SELECT 23658,80,'2013-11-01 13:18:10.053','2013-11-01...
December 24, 2013 at 7:49 am
select DISTINCT 'ID#'+CAST(ID_comment as NVARCHAR(100))+': "'+comments+'"-->'+'"'+comments+
STUFF((
SELECT DISTINCT ', '+R.name_code
from flag F1
INNER JOIN comments C1
ON F1.comment_id = C.id_comment
INNER JOIN register R
ON F1.id_reg = R.id_reg
where C1.id_comment = C1.id_comment
FOR XML PATH('')
),1,1,'')+'"'
from...
December 19, 2013 at 7:59 am
Try to use dynamic pivot, this may help you,
DROP TABLE #t1
CREATE TABLE #t1
(
EmpID INT,
[Height] NVARCHAR(100),
[Weight] NVARCHAR(100),
[Attitude] NVARCHAR(100),
[Build] NVARCHAR(100),
[DateID] INT
)
INSERT INTO #t1
VALUES(1, '5.2', '65', 'Cool', 'Good', 1),(1, '5.2', '55', 'Cool',...
December 19, 2013 at 7:14 am
Try with Charindex
DECLARE @StartTime VARCHAR(MAX),@X XML
SELECT @StartTime = '7:00 AM
12:30 PM'
DECLARE @tbl TABLE
(
ID INT
)
INSERT INTO @tbl
SELECT TOP 100 ROW_NUMBER() OVER(Order by s.object_id)
from sys.objects s , sys.objects si
select LTRIM(SUBSTRING(@StartTime,ID,CHARINDEX(CHAR(13),@StartTime+CHAR(13),ID))) from...
December 19, 2013 at 6:42 am
You can make them parameter
alter procdure date
@Fromdate varchar(10),
@todate varchar(10)
AS
--declare @Fromdate varchar(10)
--declare @todate varchar(10)
as begin
select * from master
where convert(varchar(10),@Fromdate,121) between CONVERT(varchar(10),@Todate,121) and CONVERT(varchar(10),rr.Original_Date,121)
end
December 19, 2013 at 4:43 am
Just In case you want to use CTE
DECLARE @tbl TABLE
(
RatingID INT,
Parameter_Order INT,
ProjectKey INT,
Comments NVARCHAR(MAX)
)
INSERT INTO @tbl
SELECT 792 , ...
December 19, 2013 at 4:42 am
Can you check the below code, you can only update which are in Lower case.
DECLARE @tblName TABLE
(
NAME VARCHAR(100),
Action CHAR(1)
)
INSERT INTO @tblName
SELECT '090909f','N'
UNION ALL
SELECT '090909F','N'
Update @tblName SET name = UPPER(name),Action...
December 11, 2013 at 4:30 am
DECLARE @tbl TABLE
(
ID INT IDENTITY(1,1),
SomeData VARCHAR(100)
)
INSERT INTO @tbl SELECT 'NA11345'
INSERT INTO @tbl SELECT 'NA113456'
INSERT INTO @tbl SELECT 'RA11345'
UPDATE @tbl SET SomeData = SUBSTRING(SomeData,CHARINDEX('NA',SomeData)+2,LEN(SomeData))
WHERE CHARINDEX('NA',SomeData) = 1
select * from @tbl
December 21, 2012 at 5:21 am
Please check if this can help you!!!
select CAST(20.0/7 AS INT) + CASE WHEN (20%7) > 3 THEN 1 ELSE 0 END
September 11, 2012 at 7:54 am
Hey Santa,
Can you please validate the below code
SELECT Path,FolderName,FolderSize,FileName,FileSize
FROM
(
SELECT PATH,FolderName,FolderSize,'' AS FileName,'' AS FileSize, 1 AS ID FROM @Folders
UNION
select PATH,'' AS FolderName,'' as FolderSize,FileName, FileSize,2 AS ID from @Files
)E
ORDER BY...
September 4, 2012 at 9:18 am
Farooq,
Can you please verify the below code. Looks better performance.
DECLARE @tbl TABLE (ID int identity(1,1),dt DATETIME,program VARCHAR(100),Value INT,RunningTotal INT)
INSERT INTO @tbl(dt,program,Value)
SELECT '1/1/2012','Actual', 5
UNION ALL SELECT '1/2/2012','Actual', 5
UNION ALL...
September 4, 2012 at 9:06 am
Hi ,
Can you please try the below logic
DECLARE @tbl TABLE (dt DATETIME,program VARCHAR(100),Value INT,RunningTotal INT)
INSERT INTO @tbl(dt,program,Value)
SELECT '1/1/2012','Actual', 5
UNION ALL SELECT '1/2/2012','Actual', 5
UNION ALL SELECT '1/3/2012','Actual', 1
UNION...
September 4, 2012 at 7:36 am
onclick:if_IFCode('DECLARE @tbl TABLE
(
ID SMALLINT IDENTITY(-32768,-1),
NAME VARCHAR(100)
)
INSERT INTO @tbl
SELECT 'mitesh'
select * from @tbl
INSERT INTO @tbl
SELECT 'mitesh'
select * from @tbl');
March 6, 2012 at 7:17 am
--Compareandinsertdeltaintotable,inonesqlstatement
Insert into #cmpAB
([EmpNr_a],[EmpNr_b],
[Name_a],[Name_b],
[HireDT_a],[HireDT_b],
[FireDT_a],[FireDT_b]
)
SELECT a.[EmpNr],b.[EmpNr],a.[Name] , b.[Name],
a.[HireDT] , b.[HireDT] , a.[FireDT] , b.[FireDT]
FROM #tblA a INNER JOIN #tblB b
ON a.[EmpNr] = b.[EmpNr]
WHERE( a.[Name] <> b.[Name] OR a.[HireDT] <>...
November 27, 2011 at 9:34 pm
Viewing 15 posts - 31 through 45 (of 89 total)