April 22, 2013 at 11:47 am
l have the management tool already install
April 22, 2013 at 12:09 pm
fadewumi (4/22/2013)
l have the management tool already install
Great.
Start a new thread with questions you might have.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
April 22, 2013 at 12:53 pm
is there any website to learn this sql database very well
April 22, 2013 at 1:03 pm
How about this?
CREATE FUNCTION dbo.SplitString ( @string varchar(4000))
RETURNS @Result TABLE(SpiltedString VARCHAR(100))
AS
BEGIN
DECLARE @xml XML
SELECT @xml = CAST('<VALUE>'+ REPLACE(@string,',','</VALUE><VALUE>')+ '</VALUE>' AS XML)
INSERT INTO @Result
SELECT t.value('.', 'VARCHAR(100)') AS inVal
FROM @xml.nodes('/VALUE') AS x(t)
RETURN
END
GO
Create table #MYTEMP
(Id int ,
value nvarchar(100),
name varchar(50))
insert into #MYTEMP VALUES(1,'B,C,D','XYZ')
SELECT ID, fnResult.SpiltedString, name
FROM #MYTEMP
CROSS APPLY DBO.SplitString(value) as fnResult
DROP FUNCTION dbo.SplitString
DROP TABLE #MYTEMP
April 22, 2013 at 1:15 pm
is that creating table
April 22, 2013 at 1:20 pm
fadewumi (4/22/2013)
is that creating table
Ignore the post above this one of yours. I'm pretty sure it wasn't meant for you.
As Sean said earlier. please start your own thread to ask questions instead of using this one. It is just going to confuse you.
Start fresh.
April 22, 2013 at 1:40 pm
mbhandari (4/22/2013)
How about this?CREATE FUNCTION dbo.SplitString ( @string varchar(4000))
RETURNS @Result TABLE(SpiltedString VARCHAR(100))
AS
BEGIN
DECLARE @xml XML
SELECT @xml = CAST('<VALUE>'+ REPLACE(@string,',','</VALUE><VALUE>')+ '</VALUE>' AS XML)
INSERT INTO @Result
SELECT t.value('.', 'VARCHAR(100)') AS inVal
FROM @xml.nodes('/VALUE') AS x(t)
RETURN
END
GO
Create table #MYTEMP
(Id int ,
value nvarchar(100),
name varchar(50))
insert into #MYTEMP VALUES(1,'B,C,D','XYZ')
SELECT ID, fnResult.SpiltedString, name
FROM #MYTEMP
CROSS APPLY DBO.SplitString(value) as fnResult
DROP FUNCTION dbo.SplitString
DROP TABLE #MYTEMP
Please see the article in my signature about splitting strings. It will show you a better alternative than this type of xml splitter for splitting strings. It includes code almost exactly the same as this splitter and demonstrates a way that is WAY faster.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
April 22, 2013 at 2:30 pm
fadewumi (4/22/2013)
is there any website to learn this sql database very well
Heh... you're on it now. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 8 posts - 16 through 22 (of 22 total)
You must be logged in to reply to this topic. Login to reply