I have the following values in a field named (sn_font). Opaque=1;Font=Times New Roman;FontSize=10;FontBold=0;FontItalic=0;FontUnderline=0;TextColor=0,0,0;BackColor=255,255,204;Printable=1 I need to make a select statement that will give a result such as "0". If I need to select only the value for "FontItalic". How can I do this ? How can I only select the value after the sign '=' for one of the items above if it is all stored in one line in the same field ? A
Hi, If there are no spaces before and after '=' sign then Value is helpful, otherwise Value2 gives a general solution for any property: -- create table #test (sn_font varchar(200)) insert into #test values ('Opaque=1;Font=Times New Roman;FontSize=10;FontBold=0;FontItalic= 0;FontUnderline=0;TextColor=0,0,0;BackColor=255,255,204;Printable=1') -- declare @cSearch varchar(20) set @cSearch = '%FontItalic%' -- select SUBSTRING(sn_font , PATINDEX ( @cSearch , sn_font ) + 11 , 1) as Value -- ,SUBSTRING(SUBSTRING(sn_font , PATINDEX ( @cSearch , sn_font ) , len(sn_font)), PATINDEX ('%=%', SUBSTRING(sn_font , PATINDEX ( @cSearch , sn_font ) , len(sn_font))) +1, PATINDEX ('%;%', SUBSTRING(sn_font , PATINDEX ( @cSearch , sn_font ) , len(sn_font))) - PATINDEX ('%=%', SUBSTRING(sn_font , PATINDEX ( @cSearch , sn_font ) , len(sn_font)))-1) as Value2 from #test -- drop table #test -- HTH Kamran [quoted text, click to view] "Aleks" <amucino@bluedot-web.com> wrote in message news:uXImx63eHHA.4136@TK2MSFTNGP02.phx.gbl... >I have the following values in a field named (sn_font). > > Opaque=1;Font=Times New > Roman;FontSize=10;FontBold=0;FontItalic=0;FontUnderline=0;TextColor=0,0,0;BackColor=255,255,204;Printable=1 > > > I need to make a select statement that will give a result such as "0". > > If I need to select only the value for "FontItalic". > > How can I do this ? How can I only select the value after the sign '=' > for one of the items above if it is all stored in one line in the same > field ? > > A >
I actually dont want to create another table, I just want to select the value and create a recordset, if ran in query analizer simply see the result. A [quoted text, click to view] "Kamran" <ahmadkamran@gmail.com> wrote in message news:%23MUNrl4eHHA.4944@TK2MSFTNGP04.phx.gbl... > Hi, > > If there are no spaces before and after '=' sign then Value is helpful, > otherwise Value2 gives a general solution for any property: > -- > create table #test (sn_font varchar(200)) > insert into #test values ('Opaque=1;Font=Times New > Roman;FontSize=10;FontBold=0;FontItalic= > 0;FontUnderline=0;TextColor=0,0,0;BackColor=255,255,204;Printable=1') > -- > declare @cSearch varchar(20) > set @cSearch = '%FontItalic%' > -- > select SUBSTRING(sn_font , PATINDEX ( @cSearch , sn_font ) + 11 , 1) as > Value > -- > ,SUBSTRING(SUBSTRING(sn_font , PATINDEX ( @cSearch , sn_font ) , > len(sn_font)), > PATINDEX ('%=%', SUBSTRING(sn_font , PATINDEX ( @cSearch , sn_font ) , > len(sn_font))) +1, > PATINDEX ('%;%', SUBSTRING(sn_font , PATINDEX ( @cSearch , sn_font ) , > len(sn_font))) > - PATINDEX ('%=%', SUBSTRING(sn_font , PATINDEX ( @cSearch , sn_font ) , > len(sn_font)))-1) as Value2 > from #test > > -- > drop table #test > -- > > HTH > > Kamran > > "Aleks" <amucino@bluedot-web.com> wrote in message > news:uXImx63eHHA.4136@TK2MSFTNGP02.phx.gbl... >>I have the following values in a field named (sn_font). >> >> Opaque=1;Font=Times New >> Roman;FontSize=10;FontBold=0;FontItalic=0;FontUnderline=0;TextColor=0,0,0;BackColor=255,255,204;Printable=1 >> >> >> I need to make a select statement that will give a result such as "0". >> >> If I need to select only the value for "FontItalic". >> >> How can I do this ? How can I only select the value after the sign '=' >> for one of the items above if it is all stored in one line in the same >> field ? >> >> A >> > >
Hi Aleks, If you are referring to table '#test' this is a temp table for displaying example more clearly. You only need to use 'declare..., set... and SELECT...' statements in query analyzer (with your table name instead of #test in SELECT). Regards, Kamran [quoted text, click to view] "Aleks" <amucino@bluedot-web.com> wrote in message news:%230mvNp4eHHA.4020@TK2MSFTNGP06.phx.gbl... >I actually dont want to create another table, I just want to select the >value and create a recordset, if ran in query analizer simply see the >result. > > A > > > "Kamran" <ahmadkamran@gmail.com> wrote in message > news:%23MUNrl4eHHA.4944@TK2MSFTNGP04.phx.gbl... >> Hi, >> >> If there are no spaces before and after '=' sign then Value is helpful, >> otherwise Value2 gives a general solution for any property: >> -- >> create table #test (sn_font varchar(200)) >> insert into #test values ('Opaque=1;Font=Times New >> Roman;FontSize=10;FontBold=0;FontItalic= >> 0;FontUnderline=0;TextColor=0,0,0;BackColor=255,255,204;Printable=1') >> -- >> declare @cSearch varchar(20) >> set @cSearch = '%FontItalic%' >> -- >> select SUBSTRING(sn_font , PATINDEX ( @cSearch , sn_font ) + 11 , 1) as >> Value >> -- >> ,SUBSTRING(SUBSTRING(sn_font , PATINDEX ( @cSearch , sn_font ) , >> len(sn_font)), >> PATINDEX ('%=%', SUBSTRING(sn_font , PATINDEX ( @cSearch , sn_font ) , >> len(sn_font))) +1, >> PATINDEX ('%;%', SUBSTRING(sn_font , PATINDEX ( @cSearch , sn_font ) , >> len(sn_font))) >> - PATINDEX ('%=%', SUBSTRING(sn_font , PATINDEX ( @cSearch , sn_font ) , >> len(sn_font)))-1) as Value2 >> from #test >> >> -- >> drop table #test >> -- >> >> HTH >> >> Kamran >> >> "Aleks" <amucino@bluedot-web.com> wrote in message >> news:uXImx63eHHA.4136@TK2MSFTNGP02.phx.gbl... >>>I have the following values in a field named (sn_font). >>> >>> Opaque=1;Font=Times New >>> Roman;FontSize=10;FontBold=0;FontItalic=0;FontUnderline=0;TextColor=0,0,0;BackColor=255,255,204;Printable=1 >>> >>> >>> I need to make a select statement that will give a result such as "0". >>> >>> If I need to select only the value for "FontItalic". >>> >>> How can I do this ? How can I only select the value after the sign '=' >>> for one of the items above if it is all stored in one line in the same >>> field ? >>> >>> A >>> >> >> > >
Don't see what you're looking for? Try a search.
|