Extracting a portion of a value out of a database column using SQL server -
i'm trying extract portion of value out of database column using sql server. example below works in simple context varchar field. result is: &kickstart& want.
i want same when retrieving column database. sql not doing. i'm thinking easy not seeing.
declare @filename varchar(20) = '&kickstart&.cfg' declare @startpos integer = 0 declare @filenamenoext varchar(20) select @filenamenoext = left(@filename,( (charindex('.', @filename, 0)) - 1)) select @filenamenoext
here sql statement can't seem work me:
declare @filenamenoext varchar(20) select i.installfiletype installfiletype, o.oslabel oslabel, select @filenamenoext = (left(oi.filename,( (charindex('.', oi.filename, 0) ) - 1) )) filenamenoext, oi.filename filename dbo.operatingsysteminstallfiles oi join dbo.installfiletypes on oi.installfiletypeid = i.installfiletypeid join dbo.operatingsystems o on oi.operatingsystemid = o.operatingsystemid
why need variable @ all? what's wrong with:
select i.installfiletype installfiletype, o.oslabel oslabel, left(oi.filename,( (charindex('.', oi.filename, 0) ) - 1) ) filenamenoext, oi.filename filename dbo.operatingsysteminstallfiles oi join dbo.installfiletypes on oi.installfiletypeid = i.installfiletypeid join dbo.operatingsystems o on oi.operatingsystemid = o.operatingsystemid
Comments
Post a Comment