Viewing 15 posts - 706 through 720 (of 1,156 total)
If you copy your own code in an earlier post...
Declare @C Table....
Some inserts....
Down to...Declare @r table ... eg skip the while loop and try this instead...
Select c1.ConsultantID, c1.Level, c2.Level, c1.Title,...
February 11, 2008 at 9:06 am
Additonally, the results of a group by are skewed because a person can maintain a level for months at a time, thus the count would be false because it would...
February 11, 2008 at 7:14 am
I would have used Group By and Having Clauses
Select Title, Max(PeriodEndDate) as PeriodEndDate
from YourTableName
group by ConsultantId, Level, Title
having Count(PeriodEndDate) > 1
Unfortuantely, this does not produce the desired result....
February 11, 2008 at 7:12 am
Mark,
Good code, I knew this could be done with a CTE, although I am just starting to learn/use them. I took the logic from your code and transformed the...
February 10, 2008 at 9:07 am
Not sure I get the select 1,2,3 union all part. I understand union all, but not 1,2,3.
I was just showing an example of how to union column data with data...
February 8, 2008 at 2:14 pm
Dump your union statements into temp tables. Then you can union a select *, which will drastically cut down on the size of your sql string.
select 1,2,3 union all
select...
February 8, 2008 at 1:58 pm
Change the variable to nvarchar(max) and that will hold up to 2gb of string.
February 8, 2008 at 1:45 pm
Alorenzini,
I tried to avoid using a type of cursor for this query but I could not avoid it. Maybe some of the others guys will have some better methods....
February 8, 2008 at 12:56 pm
Thanks Adam. Where do I pass in the worksheet name? This is a portion of my sp:
Create procedure spAttendanceWDA
@WDA smallint,
@Sheet NVARCHAR(25)
AS
BEGIN TRY
BEGIN TRANSACTION
DECLARE @sql NVARCHAR(500)
SET @sql = N'
INSERT INTO...
February 8, 2008 at 12:13 pm
You have to use dynamic SQL
DECLARE @Sheet NVARCHAR(25),
@sql NVARCHAR(500)
SET @Sheet = '[Sheet1$]'
SET @sql = N'
INSERT INTO OPENROWSET(''Microsoft.Jet.OLEDB.4.0'',
''Excel 8.0;Database=c:\test.xls;'',
''SELECT * FROM ' + @Sheet + ''')
SELECT * FROM MyTable
'
EXEC...
February 8, 2008 at 10:31 am
I want to have the following results :
101
201
301
I believe some of your tags were stripped. If you are trying to post XML use brackets instead.
e.g.
[tag]...
February 8, 2008 at 9:31 am
SELECT DISTINCT b.ConsultantID,
b.AchieveLevel,
b.AchieveTitle,
b.PeriodEndDate
FROM #Temp a
INNER JOIN #Temp b ON a.ConsultantID = b.ConsultantID
AND a.PaidLevel =b.AchieveLevel AND a.PeriodEndDate < b.PeriodEndDate
ORDER BY b.PeriodEndDate
This returns the entire recordset not the...
February 8, 2008 at 9:09 am
You have something wrong, take a look my test data:
DECLARE @C TABLE(
ConsultantID CHAR(7),
Level CHAR(2),
Title CHAR(25),
PeriodEndDate DATETIME
)
INSERT INTO @C
SELECT '0002617', '02', 'Consultant', '2001-08-31' UNION ALL
SELECT '0002617', '04', 'Team Leader', '2002-03-31' UNION...
February 8, 2008 at 9:05 am
You need quotes around the path
bcp.exe Testdatabase.dbo.test in "C:/1.txt" -S Anand -U kumar -P kumar -t "," -r "" -c'
February 8, 2008 at 9:02 am
This query will yeild the same results
SELECT DISTINCT b.ConsultantID, b.Level, b.Title, b.PeriodEndDate
FROM @C a INNER JOIN @C b ON a.ConsultantID = b.ConsultantID
AND a.Level = b.Level AND a.PeriodEndDate < b.PeriodEndDate
ORDER BY...
February 8, 2008 at 8:32 am
Viewing 15 posts - 706 through 720 (of 1,156 total)