Viewing 15 posts - 7,156 through 7,170 (of 10,144 total)
Why do you think the query should return only one row (or none) regardless of how many rows may or may not match the filter?
I'm not sure if this...
October 21, 2010 at 8:14 am
MonsterRocks (10/21/2010)
then how to convert a varchar type variable into datetime type?..
Look up CONVERT in BOL, and choose the 'Style' which matches your text date. 106 looks promising even though...
October 21, 2010 at 7:10 am
Humble apologies. Revised code attached.
Declare @t Table
(
id int,
EmpName nvarchar(500),
...
October 21, 2010 at 6:56 am
What datatype are the 'date' columns in your table?
October 21, 2010 at 6:38 am
sharath.chalamgari (10/21/2010)
Really i didn't understand the solution that is posted here.Please can some one explain me what exactly the Query is doing.
Sure. Here's a start:
-- create a sequence table (this...
October 21, 2010 at 5:22 am
MonsterRocks (10/21/2010)
oh....Thanks a lot.... thanks Chris and gail....
Study the code, if there's anything you are unsure of, then please ask 🙂
October 21, 2010 at 4:50 am
You don't need a cursor for this, it's a simple UPDATE...FROM:
UPDATE l SET
CAL_HEADER_ID= @PVC_CALENDAR_HEADER_ID,
PERIOD_NAME= t.ATTRIBUTE2, --@lvc_period_name,
FROM_DATE= CONVERT(VARCHAR(11),LTRIM(RTRIM(t.ATTRIBUTE3)), 106), --@ld_from_date_1,
TO_DATE= CONVERT(VARCHAR(11),LTRIM(RTRIM(t.ATTRIBUTE4)), 106), --@ld_to_date_1,
QUARTER_NUM= t.ATTRIBUTE5, --@li_quarter_num,
F_YEAR= t.ATTRIBUTE6, --@lvc_f_year,
ADJUSTING_PERIOD = t.ATTRIBUTE7, --@li_adjusting_period,
TRN= @PBI_TRN,
STATUS=...
October 21, 2010 at 4:42 am
SELECT s.*, x.*
FROM @t s
CROSS APPLY (
SELECT EmpNamePart = SUBSTRING(s.EmpName, b, e), b, e
FROM (
SELECT
n.n AS b, -- delimiter at beginning of string
ISNULL(NULLIF(CHARINDEX(',', s.EmpName, n.n+1), 0), LEN(s.EmpName)+1)-1...
October 21, 2010 at 4:17 am
When you wrapped your query in another SELECT (sometimes - usefully - known as an onion select), you removed the DISTINCT. Remember "ORDER BY items must appear in the select...
October 20, 2010 at 7:48 am
Just as the message says,
Msg 145, Level 15, State 1, Line 14
ORDER BY items must appear in the select list if SELECT DISTINCT is specified.
Try this, which works
;WITH TestCTE...
October 20, 2010 at 7:07 am
Sanjay-940444 (10/20/2010)
I have one question hereDoes SQL Server guarantee that update will be done strictly in top down manner?
I didnt find it writtem anywhere in BOL.
The update is performed strictly...
October 20, 2010 at 6:39 am
You don't. You DECLARE it, then use it, exactly the same as you might in an SSMS window.
Can you give us a few more details of what it is you...
October 20, 2010 at 5:38 am
Tom.Thomson (10/19/2010)
Ray K (10/19/2010)
How about . . . neat things to do or places to see...
October 20, 2010 at 5:05 am
mpalaparthi (10/18/2010)
I have a question.... I have 3 tables (table1, table 2 and table3)
table1: ...
October 19, 2010 at 6:39 am
Viewing 15 posts - 7,156 through 7,170 (of 10,144 total)