SQLTeam.com | Weblogs | Forums

Select column values seperating from commas using query


#1

I have a table - OP_TransactionProducts
CREATE TABLE [dbo].[OP_TransactionProducts](

[prod_id] [numeric](18, 0) IDENTITY(1,1) NOT NULL,

[M_idno] [numeric](18, 0) NULL,

[MS_idno] [numeric](18, 0) NULL,

[productid] [numeric](18, 0) NULL,

[productname] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

[OS_GS_IdNo] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

[OF_FeeHeadcode] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

[accountno] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

CONSTRAINT [PK_OP_TransactionProducts1] PRIMARY KEY CLUSTERED

(

[prod_id] ASC

)WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]


I want to get prod_id from below shown table of OS_GS_IdNo = 8 and
FeeHeadcode = 451 . How to write query for that? Could anyone please help me.....
Table with values


#2

is this?

select prod_id from [dbo].[OP_TransactionProducts]
where OS_GS_IdNo like '%,8,%' and
FeeHeadcode like '%,451,%'