kranthi111 Posted January 28, 2013 Author Report Posted January 28, 2013 [quote name='loveindia' timestamp='1359218356' post='1303181430'] query raayadam ardam ayyindi baa.. oka chinna question enti antey, nuvvu cursor vaadi savocchaa??? I am asking because, okka row aitey query lo cheyocchu... but anni records in a table antey you have to use cursor ani naa feeling.. One time use antey, just use that it will be fine... I can give the query.. [/quote] one time kaadhu daily run cheyali like ETL.. ne query pampinchu try chestha...
loveindia Posted January 30, 2013 Report Posted January 30, 2013 Dude here is the solution... for the late reply.. First ee function create chey... [code] CREATE FUNCTION [dbo].[ufn_DelimitedListToTable](@String varchar(max), @Delimiter varchar(10)) returns @result TABLE (id int identity(1,1),data varchar(max)) as begin declare @pos int, @delimiter_len int declare @substring varchar(max) select @delimiter_len = len(@delimiter) set @delimiter = '%' + ltrim(rtrim(@delimiter)) + '%' select @pos = 1 if len(@String)<1 or @String is null return while @pos!= 0 begin set @pos = patindex(@Delimiter,@String) if @pos!=0 set @substring = left(@String,@pos - 1) else set @substring = @String if(len(@substring)>0) insert into @result(data) values(@substring) set @String = right(@String,len(@String) - @pos- @delimiter_len+1) if len(@String) = 0 break end return end Then do this example in your query.. begin select * from dbo.ufn_DelimitedListToTable( REPLACE('SDFSS-32RDS-SFDF3-DSFW3-DSF22 sdfeefgfeew SfdSS-3sdDS-SFDF3-3SgW3-DSsd2',' ','<>') , '<>') where LEN(data) =29 end [/code] Enjoy .... Just data badulu give your column name there in the select statement and test... all the best... please post if it is working or not...
deals2buy Posted January 30, 2013 Report Posted January 30, 2013 naakasalu question ey ardham kaaledu love baba [img]http://www.manadb.com/Smileys/default/you_rock.gif[/img]
Darling999 Posted January 30, 2013 Report Posted January 30, 2013 [quote name='loveindia' timestamp='1359561149' post='1303201152'] Dude here is the solution... for the late reply.. First ee function create chey... [code] CREATE FUNCTION [dbo].[ufn_DelimitedListToTable](@String varchar(max), @Delimiter varchar(10)) returns @result TABLE (id int identity(1,1),data varchar(max)) as begin declare @pos int, @delimiter_len int declare @substring varchar(max) select @delimiter_len = len(@delimiter) set @delimiter = '%' + ltrim(rtrim(@delimiter)) + '%' select @pos = 1 if len(@String)<1 or @String is null return while @pos!= 0 begin set @pos = patindex(@Delimiter,@String) if @pos!=0 set @substring = left(@String,@pos - 1) else set @substring = @String if(len(@substring)>0) insert into @result(data) values(@substring) set @String = right(@String,len(@String) - @pos- @delimiter_len+1) if len(@String) = 0 break end return end Then do this example in your query.. begin select * from dbo.ufn_DelimitedListToTable( REPLACE('SDFSS-32RDS-SFDF3-DSFW3-DSF22 sdfeefgfeew SfdSS-3sdDS-SFDF3-3SgW3-DSsd2',' ','<>') , '<>') where LEN(data) =29 end [/code] Enjoy .... Just data badulu give your column name there in the select statement and test... all the best... please post if it is working or not... [/quote] This is a good one dude, naaku functions assalu raavu sarigga, nenu inkaa query ey raastunna. good work. keep going
loveindia Posted January 30, 2013 Report Posted January 30, 2013 [quote name='Kaarthikeya' timestamp='1359561357' post='1303201174'] naakasalu question ey ardham kaaledu love baba [img]http://www.manadb.com/Smileys/default/you_rock.gif[/img] [/quote] Thank you re.. Karthikeya.. All SQL Developers Rawk re...
loveindia Posted January 30, 2013 Report Posted January 30, 2013 [quote name='DARLING...' timestamp='1359561706' post='1303201204'] This is a good one dude, naaku functions assalu raavu sarigga, nenu inkaa query ey raastunna. good work. keep going [/quote] function kaavali annadu ani function raasaanu darling.. denni manodu ela vaadukuntaadoo tana istam inka...
Darling999 Posted January 30, 2013 Report Posted January 30, 2013 [quote name='loveindia' timestamp='1359565487' post='1303201561'] function kaavali annadu ani function raasaanu darling.. denni manodu ela vaadukuntaadoo tana istam inka... [/quote] [size=4] [/size]
deals2buy Posted January 30, 2013 Report Posted January 30, 2013 [quote name='loveindia' timestamp='1359565487' post='1303201561'] function kaavali annadu ani function raasaanu darling.. denni manodu ela vaadukuntaadoo tana istam inka... [/quote] nenu ippati varaku functions & cursors tappa anni raasanu almost SQL lo Cursors not good for performance antaru kadaa Also Funtions ekkada use chestaru asalu?
loveindia Posted January 30, 2013 Report Posted January 30, 2013 [quote name='Kaarthikeya' timestamp='1359576792' post='1303203044'] nenu ippati varaku functions & cursors tappa anni raasanu almost SQL lo Cursors not good for performance antaru kadaa Also Funtions ekkada use chestaru asalu? [/quote] row by row operation avasaram annappudu, there is no other option than cursors.. Yes, Cursors affect the performance drastically, if you run it over million records. For like small data sets its fine. and also there are different types of cursors also that will serve the purpose. if that is a not the case at all, oka recursive cte raasi, daantlo id generate chesi, ee function ki map cheyocchu.. long procedure though.. functions and procedures are kind of same but you use procedures for creating result sets or so, where as you use functions to manipulate those result sets .. lets say, ABCDEFGH anedi nee output anukoo stored proc lo.. using a function , you can camel case it to Abcdefgh ani.. meaning--> Procedures can or need not return anything where as function should return one value or table. (Scalar functions and table valued functions). -->you cannot use result sets of proc's to join another table, but from functions you can. I hope you understood...
puli_keka Posted February 1, 2013 Report Posted February 1, 2013 [quote name='kranthi111' timestamp='1359161660' post='1303178747'] adhi guids kaadhu X-B-O-X codes.. first time vachevi kanukunna second time vachevi em cheyalo ardham avatledhu.. [/quote] x b o x aaaa.. endhi nuvvu ms aa leka valla partner aa. codes 5x5 anevi nenu roju vine vaade words...
loveindia Posted February 1, 2013 Report Posted February 1, 2013 [quote name='puli_keka' timestamp='1359713125' post='1303203398'] x b o x aaaa.. endhi nuvvu ms aa leka valla partner aa. codes 5x5 anevi nenu roju vine vaade words... [/quote] thread starter might be working for MS. but through implementation partner i guess..
deals2buy Posted February 1, 2013 Report Posted February 1, 2013 [quote name='loveindia' timestamp='1359733287' post='1303204129'] thread starter might be working for MS. but through implementation partner i guess.. [/quote] mana thread lo oka question adigaanu chudu
Darling999 Posted February 1, 2013 Report Posted February 1, 2013 [quote name='loveindia' timestamp='1359578262' post='1303203319'] row by row operation avasaram annappudu, there is no other option than cursors.. Yes, Cursors affect the performance drastically, if you run it over million records. For like small data sets its fine. and also there are different types of cursors also that will serve the purpose. if that is a not the case at all, oka recursive cte raasi, daantlo id generate chesi, ee function ki map cheyocchu.. long procedure though.. functions and procedures are kind of same but you use procedures for creating result sets or so, where as you use functions to manipulate those result sets .. lets say, ABCDEFGH anedi nee output anukoo stored proc lo.. using a function , you can camel case it to Abcdefgh ani.. meaning--> Procedures can or need not return anything where as function should return one value or table. (Scalar functions and table valued functions). -->you cannot use result sets of proc's to join another table, but from functions you can. I hope you understood... [/quote] Good explanation. Keep going
deals2buy Posted February 1, 2013 Report Posted February 1, 2013 [quote name='DARLING...' timestamp='1359756844' post='1303207510'] Good explanation. Keep going [/quote] DARLINGU..mana thread lo oka question asked see
Darling999 Posted February 1, 2013 Report Posted February 1, 2013 [quote name='Kaarthikeya' timestamp='1359757113' post='1303207551'] DARLINGU..mana thread lo oka question asked see [/quote]avnaa driving lo unna mama oka 39 mins padtadi naaku
Recommended Posts