Viewing 15 posts - 811 through 825 (of 2,007 total)
SKYBVI (3/7/2012)
I dont think DDL is needed and sample data i already put..Leave the question if u can't help.
Everyone that has posted in this thread could help. But you seem...
March 7, 2012 at 7:42 am
This works without leaving you open to SQL injection.
DECLARE @TableName AS NVARCHAR(20) = 'work', @sql AS NVARCHAR(MAX);
WITH p1 AS (
SELECT sqlStmt, ROW_NUMBER() OVER(ORDER BY ord, (SELECT NULL)) AS rn, col,...
March 7, 2012 at 7:25 am
jcrawf02 (3/7/2012)
Evil Kraig F (3/6/2012)
SQLRNNR (3/6/2012)
jcrawf02 (3/6/2012)
Evil Kraig F (3/6/2012)
If, for some reason, you just can't seem to get the login for SSC...
March 7, 2012 at 7:19 am
Jeff Moden (3/7/2012)
March 7, 2012 at 6:57 am
R.P.Rozema (3/7/2012)
March 7, 2012 at 6:43 am
Thanks to R.P.Rozema for the sample data that the OP "forgot" 😉
Here's another way:
WITH CTE
AS (SELECT OldID, NewID, NewID AS CurrentID
FROM #cref
UNION...
March 7, 2012 at 6:17 am
I missed this thread until this morning, I want to play 😀
Here's a bit of a mathematical answer to pivoting: -
SELECT
SUM(eachGroup) AS Total,
SUM(eachGroup*(1-ABS(SIGN(IGroup-1)))) AS Group1,
SUM(eachGroup*(1-ABS(SIGN(IGroup-2)))) AS Group2,
SUM(eachGroup*(1-ABS(SIGN(IGroup-3)))) AS Group3,
SUM(eachGroup*(1-ABS(SIGN(IGroup-4))))...
March 7, 2012 at 2:46 am
nilesh k (3/6/2012)
both the options are giving syntax error 🙁
Paste exactly what you tried. There is no syntax error in either of the code snippets I posted.
March 6, 2012 at 8:43 am
jcb (3/6/2012)
create table TESTE (PK int, C1 char(1), C2 char(1), C3 char(1), C4 char(1), C5 char(1))
GO
insert into TESTE values
(1, 'a',...
March 6, 2012 at 8:41 am
nilesh k (3/6/2012)
It...
March 6, 2012 at 7:47 am
nilesh k (3/6/2012)
What if there are n number of columns n table with ID as unique key?
Select * , MAX[Posted D/T] from MyTable
It is giving me below...
March 6, 2012 at 7:41 am
nilesh k (3/6/2012)
oops ...i framed it wrong.i need record set based on lateset post D/T
Like this: -
Cadavre (3/6/2012)
SELECT segment, MAX([Posted D/T])FROM yourTable
GROUP BY segment
March 6, 2012 at 7:28 am
nilesh k (3/6/2012)
segment Posted D/T
Test 1 06/06/2012 10:00 AM
Test 1 06/06/201210 11:00...
March 6, 2012 at 7:24 am
Only way I can think of would be to use a CLR. Do a try catch block to convert to XML, if it fails then return 0 if it passes...
March 6, 2012 at 5:50 am
jcb (3/6/2012)
Are you trying some sort ofselect ISNULL(c1,'')+ISNULL(c2,'')+...
?
Nope, the OP wanted to be able to only select the column if the data is not null and originally wanted the solution...
March 6, 2012 at 4:27 am
Viewing 15 posts - 811 through 825 (of 2,007 total)