Click here to Skip to main content
15,881,173 members
Home / Discussions / Database
   

Database

 
GeneralRe: Cannot Register New Server in SQL Server 2008 Pin
Kujtim Hyseni24-Jun-12 22:45
Kujtim Hyseni24-Jun-12 22:45 
GeneralRe: Cannot Register New Server in SQL Server 2008 Pin
jschell25-Jun-12 9:34
jschell25-Jun-12 9:34 
GeneralRe: Cannot Register New Server in SQL Server 2008 Pin
Kujtim Hyseni25-Jun-12 10:35
Kujtim Hyseni25-Jun-12 10:35 
GeneralRe: Cannot Register New Server in SQL Server 2008 Pin
jschell26-Jun-12 8:09
jschell26-Jun-12 8:09 
AnswerRe: Cannot Register New Server in SQL Server 2008 Pin
Eddy Vluggen25-Jun-12 1:23
professionalEddy Vluggen25-Jun-12 1:23 
QuestionInserting rows dynamiccaly on based on calculation Pin
vkap20-Jun-12 11:45
vkap20-Jun-12 11:45 
AnswerRe: Inserting rows dynamiccaly on based on calculation Pin
Mycroft Holmes20-Jun-12 13:05
professionalMycroft Holmes20-Jun-12 13:05 
AnswerRe: Inserting rows dynamiccaly on based on calculation Pin
__TR__3-Jul-12 20:41
__TR__3-Jul-12 20:41 
Try this

CREATE TABLE #Temp
(
	ID INT IDENTITY(1,1),
	col1 VARCHAR(50),
	Col2 VARCHAR(50),
	Col3 VARCHAR(50),
	position VARCHAR(50)
)


CREATE TABLE #Temp2
(
	col1 VARCHAR(50),
	Col2 VARCHAR(50),
	Col3 VARCHAR(50),
	position VARCHAR(50)
)


 
INSERT INTO #Temp
SELECT 'aaa', 'rack1', '1-3', '3' UNION
SELECT 'bbb', 'rack2', '22-23', '2' UNION
SELECT 'ccc', 'rack3', '19-20', '2' 



DECLARE @TotalRowCount  INT
DECLARE @RowCount INT
DECLARE @Positon INT
DECLARE @I INT

SET @RowCount = 1

SELECT @TotalRowCount = COUNT(*) FROM #Temp

WHILE @RowCount <= @TotalRowCount
BEGIN

	SELECT @Positon = Position FROM #Temp WHERE Id = @RowCount

	SET @I = 1

	WHILE @I <= @Positon
	BEGIN

		INSERT INTO #Temp2
		SELECT Col1, Col2, Col3, (SUBSTRING(Col3,0,CHARINDEX('-',Col3)) + @I - 1) FROM #Temp  WHERE Id = @RowCount
		
		SET @I = @I + 1
	END
	
	SET @RowCount = @RowCount + 1
	
END

SELECT * FROM #Temp2



DROP TABLE #Temp
DROP TABLE #Temp2

Questionlan chat software Pin
Member 913183919-Jun-12 1:42
Member 913183919-Jun-12 1:42 
AnswerRe: lan chat software Pin
Richard MacCutchan19-Jun-12 2:01
mveRichard MacCutchan19-Jun-12 2:01 
AnswerRe: lan chat software Pin
Eddy Vluggen19-Jun-12 2:36
professionalEddy Vluggen19-Jun-12 2:36 
AnswerRe: lan chat software Pin
Paul Conrad19-Jun-12 8:19
professionalPaul Conrad19-Jun-12 8:19 
QuestionError 1064,.... please Help Pin
Jassim Rahma16-Jun-12 0:10
Jassim Rahma16-Jun-12 0:10 
AnswerRe: Error 1064,.... please Help Pin
Mycroft Holmes16-Jun-12 3:14
professionalMycroft Holmes16-Jun-12 3:14 
Questionif - else statement in sql Pin
begg15-Jun-12 8:36
begg15-Jun-12 8:36 
AnswerRe: if - else statement in sql Pin
Corporal Agarn15-Jun-12 8:41
professionalCorporal Agarn15-Jun-12 8:41 
AnswerRe: if - else statement in sql Pin
Michael Potter15-Jun-12 10:18
Michael Potter15-Jun-12 10:18 
AnswerRe: if - else statement in sql Pin
vvashishta18-Jun-12 19:49
vvashishta18-Jun-12 19:49 
AnswerRe: if - else statement in sql Pin
rimazuc20-Jun-12 5:31
rimazuc20-Jun-12 5:31 
AnswerRe: if - else statement in sql Pin
rimazuc20-Jun-12 5:40
rimazuc20-Jun-12 5:40 
AnswerRe: if - else statement in sql Pin
hearthofmine24-Jun-12 22:33
hearthofmine24-Jun-12 22:33 
QuestionHow can i select all dates between date range? Pin
RA|-|UL PATEL15-Jun-12 3:30
RA|-|UL PATEL15-Jun-12 3:30 
AnswerRe: How can i select all dates between date range? Pin
bobrien10015-Jun-12 8:11
bobrien10015-Jun-12 8:11 
GeneralRe: How can i select all dates between date range? Pin
Corporal Agarn15-Jun-12 8:44
professionalCorporal Agarn15-Jun-12 8:44 
AnswerRe: How can i select all dates between date range? Pin
Mycroft Holmes15-Jun-12 13:44
professionalMycroft Holmes15-Jun-12 13:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.