Click here to Skip to main content
15,897,273 members
Home / Discussions / Database
   

Database

 
QuestionMS ACESS setting cutureinfo Pin
udikantz1-Apr-09 18:09
udikantz1-Apr-09 18:09 
AnswerRe: MS ACESS setting cutureinfo Pin
Eddy Vluggen2-Apr-09 0:04
professionalEddy Vluggen2-Apr-09 0:04 
GeneralRe: MS ACESS setting cutureinfo Pin
udikantz2-Apr-09 1:02
udikantz2-Apr-09 1:02 
QuestionFTP snapshot folder for merge replication Pin
Jay Royall1-Apr-09 3:49
Jay Royall1-Apr-09 3:49 
AnswerRe: FTP snapshot folder for merge replication Pin
Jay Royall1-Apr-09 5:40
Jay Royall1-Apr-09 5:40 
QuestionMS SQL Server 2005 Linked server login timeout Pin
Steven J Jowett1-Apr-09 1:16
Steven J Jowett1-Apr-09 1:16 
AnswerRe: MS SQL Server 2005 Linked server login timeout Pin
Member 34721671-Apr-09 15:12
Member 34721671-Apr-09 15:12 
QuestionSQL Insert [modified] Pin
Vimalsoft(Pty) Ltd31-Mar-09 23:59
professionalVimalsoft(Pty) Ltd31-Mar-09 23:59 
Good Day all.

I have the Following Query
SELECT T.ID, T.CYCLETEMPLATES 
FROM TBL_TERM T 


This Brings back something like this

ID      CycleTemplate
==============================================================
5   |	1010101010101000100010101010100010000000000000000000
6   |	1000000000000000000000000000000010000000000000000000


Now i have another table Defined like this

CREATE TABLE DBO.REC_TERM_CYCLE
(
ID INT IDENTITY(1,1) PRIMARY KEY NOT NULL,
TERM INT NULL,
CYCLE VARCHAR(10) NULL
)


Let me explain the Logic of a Cycle template,

1010101010101000100010101010100010000000000000000000


The "1"'s represent the position of the template. if i can return this, it will bring me

1,3,5,7,9,11,12,16
................

So i want to run an Insert statement on the table REC_TERM_CYCLE like this

INSERT INTO DBO.REC_TERM_CYCLE
VALUES(ID,cycles)


Now the Cycles are the individual number retrieved from that long string. but now this must go to a table to retrieve the Cycles Template long string and add the id and the position of the cycle

i have the below code


SELECT T.ID, T.CYCLETEMPLATES 
FROM TBL_TERM T 
Declare @Len int
SET @Len = LEN(T.CYCLETEMPLATES)
Declare @Counter int
SET @Counter = 1
WHILE @Counter < = @Len
BEGIN
	if (SUBSTRING(T.CYCLETEMPLATES,@Counter,1)='1')
		INSERT INTO DBO.REC_TERM_CYCLE
		VALUES(T.ID,@Counter)
		SET @Counter = @Counter + 1
END

PRINT 'INSERTED' + T.ID '' + @Counter ''


Thanks

Vuyiswa Maseko,

Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."

C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
www.ITS.co.za

modified on Wednesday, April 1, 2009 6:07 AM

AnswerRe: SQL Insert Pin
Vimalsoft(Pty) Ltd1-Apr-09 4:17
professionalVimalsoft(Pty) Ltd1-Apr-09 4:17 
QuestionCreating Demo Data Pin
Brendan Vogt31-Mar-09 23:03
Brendan Vogt31-Mar-09 23:03 
AnswerRe: Creating Demo Data Pin
Henry Minute1-Apr-09 1:19
Henry Minute1-Apr-09 1:19 
Questionhow this query can be written in sql server Pin
lakshmichawala31-Mar-09 19:00
lakshmichawala31-Mar-09 19:00 
AnswerRe: how this query can be written in sql server Pin
Blue_Boy31-Mar-09 21:02
Blue_Boy31-Mar-09 21:02 
GeneralRe: how this query can be written in sql server Pin
lakshmichawala31-Mar-09 21:05
lakshmichawala31-Mar-09 21:05 
GeneralRe: how this query can be written in sql server Pin
Blue_Boy31-Mar-09 21:16
Blue_Boy31-Mar-09 21:16 
GeneralRe: how this query can be written in sql server Pin
lakshmichawala31-Mar-09 21:25
lakshmichawala31-Mar-09 21:25 
GeneralRe: how this query can be written in sql server Pin
Eddy Vluggen1-Apr-09 0:39
professionalEddy Vluggen1-Apr-09 0:39 
QuestionLooking for good tool to convert Oracle - sql server Pin
E_Gold31-Mar-09 18:18
E_Gold31-Mar-09 18:18 
QuestionSequences?? Pin
Muammar©31-Mar-09 6:31
Muammar©31-Mar-09 6:31 
AnswerRe: Sequences?? Pin
Blue_Boy31-Mar-09 7:16
Blue_Boy31-Mar-09 7:16 
GeneralRe: Sequences?? Pin
Muammar©31-Mar-09 18:47
Muammar©31-Mar-09 18:47 
GeneralRe: Sequences?? Pin
Blue_Boy31-Mar-09 21:04
Blue_Boy31-Mar-09 21:04 
AnswerRe: Sequences?? Pin
Jörgen Andersson31-Mar-09 8:45
professionalJörgen Andersson31-Mar-09 8:45 
GeneralRe: Sequences?? Pin
Muammar©31-Mar-09 18:42
Muammar©31-Mar-09 18:42 
GeneralRe: Sequences?? Pin
Jörgen Andersson31-Mar-09 21:00
professionalJörgen Andersson31-Mar-09 21:00 

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.