Viewing 15 posts - 706 through 720 (of 897 total)
Anamika (7/19/2010)
Thanks to Eugene and mthurber nice and easy way of achieving it.by the way, Mr. Paul, i still don't understand the logic behind it.
SELECT * FROM Tbl1
I think Paul...
July 19, 2010 at 10:47 pm
Paul White NZ (7/17/2010)
DECLARE @strVariable VARCHAR(100)...
July 18, 2010 at 10:57 pm
All you have to do is replace the m in the last line with m1 in your query
select id1
,orderby
,m.Name orderbyname
,m1.Name receivedbyname
from @staff m
inner join @order t
on m.id =...
July 18, 2010 at 12:57 am
Jeff Moden (7/16/2010)
Kingston Dhasian (7/16/2010)
DECLARE @strVariable VARCHAR(100)
SET @strVariable = 'J:\SQL 2008 Database Backups\High School Baseball\HighSchoolBaseball_Full.bak'
SELECTSUBSTRING( @strVariable, 1, LEN( @strVariable ) - CHARINDEX( '\', REVERSE( @strVariable ) ) )
Here i...
July 17, 2010 at 2:01 am
Try this
DECLARE @strVariable VARCHAR(100)
SET @strVariable = 'J:\SQL 2008 Database Backups\High School Baseball\HighSchoolBaseball_Full.bak'
SELECTSUBSTRING( @strVariable, 1, LEN( @strVariable ) - CHARINDEX( '\', REVERSE( @strVariable ) ) )
Here i have used the REVERSE...
July 16, 2010 at 11:42 am
This is quite a big topic and people have written whole books on it. I can give you a link of books which have the anwers to your questions in...
July 15, 2010 at 10:38 pm
This is what i could come up with.
DECLARE@tbl_OrderItems TABLE
(
OrderID INT,
Product VARCHAR(100)
)
INSERT@tbl_OrderItems
SELECT10001, 'Bananas' UNION ALL
SELECT10002, 'Apples' UNION ALL
SELECT10002, 'Pears' UNION ALL
SELECT10002, 'Oranges' UNION ALL
SELECT10003, 'Bananas' UNION ALL
SELECT10004, 'Apples' UNION ALL
SELECT10004, 'Pears'
SELECTDISTINCT...
July 14, 2010 at 3:20 am
IF OBJECT_ID( 'tempdb..#Employees' ) IS NOT NULL
DROP TABLE #Employees
DECLARE@strColumns VARCHAR(1000)
DECLARE @strQuery VARCHAR(2000)
CREATE TABLE #Employees
(
EMP_IDINT,
Contact_typeNVARCHAR(50),
Contact_NumberNVARCHAR(300)
)
INSERT INTO #Employees
SELECT 1 ,'Home' ,'92 - 51 - 225478'
UNION ALL SELECT 1, 'Cell', '92...
July 14, 2010 at 1:58 am
You can also get your desired result by replacing the LEFT JOIN IN Wayne's Code with a FULL OUTER JOIN
SELECTISNULL( t2.SID, t1.SID ) SID, ISNULL( t2.PID, t1.PID ) PID,
ISNULL( t2.Date,...
July 12, 2010 at 4:21 am
Chris Morris-439714 (6/29/2010)
eng.khiat (6/29/2010)
(
SELECT top 10 * FROM tableX ORDER BY ID DESC
) AS A
ORDER BY A.ID ASC
It gives error and when...
June 29, 2010 at 4:26 am
Try the following
; WITH cte_tableX AS
(
SELECTROW_NUMBER() OVER ( ORDER BY ID DESC ) RowNum, *
FROMtableX
)
SELECT*
FROMcte_tableX
WHERERowNum <= 10
ORDER BY RowNum DESC
Didnt test it though. But should work
June 29, 2010 at 3:30 am
Gianluca Sartori (6/25/2010)
virender.singh (6/25/2010)
derived/nested query is ok. but we will have a performance issue with this.
What kind of performance problem? The way of accessing the table suggested by Kingston isn't...
June 25, 2010 at 3:59 am
NewBeeSQL (6/25/2010)
;with cte1 as(select ROW_NUMBER() OVER(ORDER BY...
June 25, 2010 at 2:13 am
Change the block as given below, I have just used a COALESCE() function to get the desired result
;with cte1 as(select ROW_NUMBER() OVER(ORDER BY Index_code) AS 'rn',index_code,code1,code2,startdate,enddate
from #Ixtable)
select c1.index_code,c1.code1,c1.code2,c1.startdate, -- c2.startdate-1...
June 25, 2010 at 1:51 am
Viewing 15 posts - 706 through 720 (of 897 total)