January 27, 2017 at 6:41 am
DROP TABLE TestMode
CREATE TABLE TestMode
(
Mode NVARCHAR(MAX),
ANS NVARCHAR(MAX)
)
DECLARE @mode NVARCHAR(MAX)
SET @mode = 'Mode1|Mode2|Mode3'
DECLARE @Ans NVARCHAR(MAX)
SET @Ans = 'Ans1|Ans2|;Ans1|Ans2;|Ans1|Ans2'
I need a Result like below
Mode1 Ans1|Ans2
Mode2 Ans1|Ans2
Mode3 Ans1|Ans2
Kindly help me how to query for the above
i tried below its not working
INSERT INTO TestMode (Mode)
(SELECT Item FROM dbo.SplitString(@mode,'|'))
January 27, 2017 at 7:01 am
Twice in the same day π Try this thread.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
January 27, 2017 at 7:04 am
pvuser.chennai - Friday, January 27, 2017 6:41 AMDROP TABLE TestModeCREATE TABLE TestMode
(
Mode NVARCHAR(MAX),
ANS NVARCHAR(MAX)
)DECLARE @mode NVARCHAR(MAX)
SET @mode = 'Mode1|Mode2|Mode3'DECLARE @Ans NVARCHAR(MAX)
SET @Ans = 'Ans1|Ans2|;Ans1|Ans2;|Ans1|Ans2'I need a Result like below
Mode1 Ans1|Ans2
Mode2 Ans1|Ans2
Mode3 Ans1|Ans2Kindly help me how to query for the above
i tried below its not working
INSERT INTO TestMode (Mode)
(SELECT Item FROM dbo.SplitString(@mode,'|'))
Given the desired results, you need to split on the semicolon, not the pipe character.
π
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply