|
There is no build-in split function in SQL but you can create your own custom function.. You can google about this "SQL split function"
For example: A SQL Split Function
Hope it helps..
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
"Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."
|
|
|
|
|
You Can Try This
Hope It is exact What u want.
<br />
Create FUNCTION [dbo].[fn_split] (<br />
@SourceString sql_variant,<br />
@Delimiter nvarchar(10) = N','<br />
)<br />
RETURNS @Values TABLE( Position smallint IDENTITY, cValue varchar( 8000 ) , ncValue nvarchar( 4000 ) )<br />
AS<br />
BEGIN<br />
DECLARE @NormalString varchar( 8000 ) , @NationalString nvarchar( 4000 ) ,<br />
@NormalDelimiter varchar( 10 ) , @NationalDelimiter nvarchar( 10 ) ,<br />
@IsNationalChar bit , @Position int ,<br />
@NormalValue varchar( 8000 ) , @NationalValue nvarchar( 4000 )<br />
SET @Delimiter = COALESCE( @Delimiter, N',' )<br />
SET @IsNationalChar = CASE<br />
WHEN SQL_VARIANT_PROPERTY( @SourceString , 'BaseType' ) IN ( 'char' , 'varchar' )<br />
THEN 0<br />
WHEN SQL_VARIANT_PROPERTY( @SourceString , 'BaseType' ) IN ( 'nchar' , 'nvarchar' )<br />
THEN 1<br />
END<br />
IF @IsNationalChar IS NULL RETURN<br />
IF @IsNationalChar = 0<br />
BEGIN<br />
SET @NormalDelimiter = @Delimiter<br />
SET @NormalString = CAST( @SourceString AS varchar(8000) )<br />
<br />
IF LEFT( @NormalString , LEN( @NormalDelimiter ) ) = @NormalDelimiter<br />
SET @NormalString = SUBSTRING( @NormalString, LEN( @NormalDelimiter ) + 1, 8000 )<br />
IF RIGHT( @NormalString , LEN( @NormalDelimiter ) ) <> @NormalDelimiter<br />
SET @NormalString = @NormalString + @NormalDelimiter<br />
WHILE( 1 = 1 )<br />
BEGIN<br />
SET @Position = CHARINDEX( @NormalDelimiter , @NormalString ) - 1<br />
IF @Position <= 0 BREAK<br />
SET @NormalValue = LEFT( @NormalString , @Position )<br />
SET @NormalString = STUFF( @NormalString , 1 , @Position + LEN( @NormalDelimiter ), '' )<br />
INSERT INTO @Values ( cValue ) VALUES( @NormalValue )<br />
END<br />
END<br />
ELSE IF @IsNationalChar = 1<br />
BEGIN<br />
SET @NationalDelimiter = @Delimiter<br />
SET @NationalString = CAST( @SourceString AS varchar(8000) )<br />
<br />
IF LEFT( @NationalString , LEN( @NationalDelimiter ) ) = @NationalDelimiter<br />
SET @NationalString = SUBSTRING( @NationalString, LEN( @NationalDelimiter ) + 1, 4000 )<br />
IF RIGHT( @NationalString , LEN( @NationalDelimiter ) ) <> @NationalDelimiter<br />
SET @NationalString = @NationalString + @NationalDelimiter<br />
WHILE( 1 = 1 )<br />
BEGIN<br />
SET @Position = CHARINDEX( @NationalDelimiter , @NationalString ) - 1<br />
IF @Position <= 0 BREAK<br />
SET @NationalValue = LEFT( @NationalString , @Position )<br />
SET @NationalString = STUFF( @NationalString , 1 , @Position + LEN( @NationalDelimiter ), '' )<br />
INSERT INTO @Values ( ncValue ) VALUES( @NationalValue )<br />
END<br />
END<br />
RETURN<br />
END<br />
Just Do IT™ [Information Technology]™ ;->
|
|
|
|
|
Hi,
I want to access the cells address of a gridview control on click or double click...
In Windows application with DatagridView it's quite easy..
How can i get the same in asp.net gridview control
Sangram
(A battle with self)
Life is simple, we are the ones makes the living difficult
|
|
|
|
|
what you are trying to do?
if you want to postback the page then you can achieve this by adding the following attribute in RowDataBound of the gridview:
<br />
foreach TableCell cell in curRow.Cells<br />
{<br />
cell.Attributes.Add("id",cell.ClientID);<br />
cell.Attributes.Add("onclick", "javascript:document.formname.submit();");<br />
}<br />
in the event handler for the cell you can get the ID of the sender;
and if you want to do something on client side using javascript then do this:
<br />
foreach TableCell cell in curRow.Cells<br />
{<br />
cell.Attributes.Add("id",cell.ClientID);<br />
cell.Attributes.Add("onclick", "javascript:getTheCell(this);");<br />
}<br />
and in javascript file do this:
<br />
function getTheCell(cell)<br />
{<br />
alert('You clicked cell ID: '+ cell.ID);<br />
}<br />
-----
|
|
|
|
|
Hi SABhatti,
I am preparing a seatlayout type of application using a gridview. i am generating a gridview but i want to store the cells address on click in a listbox or list item and later store them in database...
I think i have descibe clearly above....
I am trying using the solution...as u gave
But If there a better way or a link where I can refer I will be glad..
Sangram
(A battle with self)
Life is simple, we are the ones makes the living difficult
|
|
|
|
|
if you are using AJAX then you can even do a partial postback and store that address on the server.
But I will suggest the javascript solution I gave you in my previous response. In that javascript function store the ID's in a hidden filed separated by comma and highlight the cells (change the backround color using stylesheet cell.className in javascript). when user submit the form get the clicked cells from hidden field, split them based on , and store them in database.
-----
|
|
|
|
|
Hi SABhatti,
I am trying the solution provided but it's not getting the cellId...
It shows in alert;
You have clicked the cell: undefined
Need urgent help please
Sangram
(A battle with self)
Life is simple, we are the ones makes the living difficult
|
|
|
|
|
ok are you doing this in rowdatabound of the gridview
<br />
foreach (TableCell cell in e.Row.Cells)<br />
{<br />
cell.Attributes.Add("id",cell.ClientID);<br />
cell.Attributes.Add("onclick", "javascript:getTheCell(this);");<br />
}<br />
<br />
and in javascript file do this:
// sorry .id is lower case
<br />
function getTheCell(cell)<br />
{<br />
alert('You clicked cell ID: '+ cell.id);<br />
}<br />
-----
|
|
|
|
|
Hi professionals,
I am planning to launch a website like youtube, but it is meant for different purpose, it will have very similar functionality to youtube, more precisely it will have:
1. Simple interface design, but professional design (I mean no graphical complications, yet great reachbility of video content).
2. Makes intensive use of AJAX to update the user-interface.
3. Needs to be able to handle thousands of users surfing the site at the same time.
4. Needs to manipulate large amounts of data in different databases efficiently.
5. Needs to embed media controls like flash video, real player, windows media player in web-pages.
6. Functionality includes user profiles, e-mailing, video rating, video commenting and everything youtube has.
I don't know what technology I should use in building this project, is it ASP .NET or PHP? I know little about ASP .NET and I know nothing about PHP.
I need to use a tool that is very productive, relatively easier and reliable to build a world-class project, I need it to be able to handle millions of records and thousands of users surfing the website simaltanously.
Any help professionals?
Thanks in advance.
-- modified at 8:13 Monday 19th November, 2007
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
Have a look at both languages - do some research on google about how they handle loads, their scalability, supportablity - their hardware dependance (you are going to need some slick hardware to handle your reqs). It must handle load balancing as I can't see a single box being able to handle what you are doing. Are your vids stored as files or blobs in a database? If a database you want a fast DB access layer with a high performance backend.
Identify different aspects of the design, research the hardware / software avaiable and your investigation will slowly point you to the correc technology.
Finally, if you know little about ASP.NET and nothing about PHP, and you are looking to write a YouTube style app, with huge hits, Iwish you the best of look. My first webapp fell over when the second user came on line at the same time as the first.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"This time yesterday, I still had 24 hours to meet the deadline I've just missed today."
|
|
|
|
|
Thanks for your answer,
but lets make things much simpler, lets say that I want to design the web interface and develop the underlying database queries for user profiles and video ratings, and let us drop the problem of video loading, lets assume that there are no videos right now.
What will be better, ASP .NET or PHP?
Thanks in advance
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
Isn't this a bit ambitious if you don't know how to use the underlying technologies. Youtube is an incredibly complex system with support for areas such as load balancing and failover support which go beyond having a basic grasp of a particular language.
Mohammad A Gdeisat wrote: I need to use a tool that is very productive, relatively easier and reliable to build a world-class project, I need it to be able to handle millions of records and thousands of users surfing the website simaltanously.
We all want that. Both PHP and ASP.NET will provide you with the tools but you still need to be able to design and code to use them to this level, and this is years worth of mastery - not days.
|
|
|
|
|
Thanks for your answer,
but lets make things much simpler, lets say that I want to design the web interface and develop the underlying database queries for user profiles and video ratings, and let us drop the problem of video loading, lets assume that there are no videos right now.
What will be better, ASP .NET or PHP?
Thanks in advance
Mohammad
And ever has it been that love knows not its own depth until the hour of separation
|
|
|
|
|
Well, you've asked on an ASP.NET forum so chances are that most people are going to reply ASP.NET. Really though, it depends on what you are trying to do and the technologies that are going to be underlying it. This question is like asking which is better a Ferrari or a Porsche? There's no right or wrong answer - only opinions and arguments about merits.
|
|
|
|
|
The core answer is that you need to give up on this project until you know one or the other, but both are well able to do what you want, the problem lies in your lack of experience. Personally, I prefer ASP.NET, but both can do what you want.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi,
My functional requirement is, to write a script in database (SP) to insert records on dynamic table.
So I nedd to return column name of specified table while i passed the table name as parameter .
Hope For Getting Clue..
|
|
|
|
|
And your clue is....
Post this in a datbase forum.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"This time yesterday, I still had 24 hours to meet the deadline I've just missed today."
|
|
|
|
|
Response.ContentType = type;
Response.WriteFile(path);
using this iam getting the download popup message as save ,open , cancel ,now using save iam saving the file in a client machine ...now the fiel is getting saved now i want the location of the file where it was saved
|
|
|
|
|
jagadeeshkumar2106 wrote: now using save iam saving the file in a client machine
You can't access the file system (easily) from the browser. The only way you can is to either write an activeX control or run the app as a HTX app.
Or I've misunderstood your problem.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"This time yesterday, I still had 24 hours to meet the deadline I've just missed today."
|
|
|
|
|
can u refer me any link that has free e-books regarding regular expressions
Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.
|
|
|
|
|
|
did u try to open this link ?
Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.
|
|
|
|
|
did U? I did and it failed. I then used this[^] to help me decide what to do. I cut and pasted teh text and hey... it worked. But that entails work on your part, which you don't like doing.
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"This time yesterday, I still had 24 hours to meet the deadline I've just missed today."
|
|
|
|
|
Yes Sir, Common sense is very uncommon.
Yesterday is a canceled check. Tomorrow is a promissory note. Today is the ready cash. USE IT.
|
|
|
|
|
|