Viewing 15 posts - 196 through 210 (of 683 total)
Since you insist...
declare @ColumnDesc table (ID int, ColumnList varchar(4000))
Insert into @ColumnDesc
Select 1,'Select A.Eno,B.Salary,C.Dept from Emp A,Payroll B,Department C'
Union All Select...
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
April 21, 2008 at 4:19 am
Another option and my preference is...
DECLARE @Rows TABLE (RowNumber INT IDENTITY(1, 1), Col1 VARCHAR(10))
INSERT @Rows SELECT 'B' UNION ALL SELECT 'A' UNION ALL SELECT 'D'
SELECT a.Col1, a.[Val 1]
FROM @Table a...
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
April 21, 2008 at 4:03 am
what I have to do is to respect the same order that is in the WHERE Clause
You can do this...
ORDER BY CASE WHEN 'B' THEN 1 WHEN 'A' THEN 2...
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
April 21, 2008 at 3:57 am
This is a lot easier in SQL 2005 since you can use 'cross apply'. In SQL 2000, I think you will have to loop through your rows using a while...
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
April 21, 2008 at 3:52 am
Another way...
SELECT * FROM INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 'MyTable'
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
April 21, 2008 at 3:45 am
You could also consider using a computed column directly on the table...
http://www.sqlservercentral.com/articles/User-Defined+functions/complexcomputedcolumns/2397/
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
April 21, 2008 at 3:42 am
@sql starts off as null, and you keep appending to it - which will always give null. You need to set @sql...
DECLARE @Count int
DECLARE @sql NVARCHAR(2000)
SET @sql = '' --...
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
April 21, 2008 at 3:35 am
Ah, I see [Val 1] must be a varchar, so perhaps you can make use of one of these...?
ORDER BY LEN([Val 1]) DESC, [Val 1] DESC
or
ORDER BY RIGHT(SPACE(20) + [Val...
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
April 21, 2008 at 3:32 am
ORDER BY [Val 1] DESC
?
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
April 21, 2008 at 3:26 am
Here are a couple of ways...
declare @x varchar(30)
set @x = '20081011192921703'
select cast(substring(@x, 1, 8) + ' ' + substring(@x, 9, 2) + ':' + substring(@x, 11, 2)
...
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
April 21, 2008 at 3:25 am
You've lost me. Give a few examples of inputs and required outputs...
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
April 21, 2008 at 2:50 am
I fear I will not be able to fit everything in the dynamic sql.
What is your basis for this fear?
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
April 21, 2008 at 1:42 am
Is it assigning the text 'Center' to the variable @Center and etc.
No. That would have to be...
SELECT @Center = 'Center', etc
It's not assigning anything - it's just selecting the value...
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
April 20, 2008 at 4:34 pm
Kaushik Kumar (4/18/2008)
thanks. This definitely gives me a starting point.also, I feel left out with FLOWR, are there any good online tutorials?
I don't know - sorry...
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
April 18, 2008 at 9:35 am
Does this help?
declare @x xml
set @x = '
<bo>
<row number="1">
<column1>value</column1>
<column2>value</column2>
<column3>value</column3>
</row>
<row number="2">
<column1>value</column1>
<column4>value</column4>
...
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
April 18, 2008 at 9:17 am
Viewing 15 posts - 196 through 210 (of 683 total)