Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 dynamic created condition

Author  Topic 

ilayaraja.ajsquare
Starting Member

8 Posts

Posted - 2010-09-27 : 02:41:22
declare @st varchar(max);
SET @st='22=23';
--if(23=22)
if (select(@st))
print 'equal';
else
print 'not equal';

how can the condition being dynamically assigned

An expression of non-boolean type specified in a context where a condition is expected

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-09-27 : 04:25:10
Read this:
http://www.sommarskog.se/dynamic_sql.html

But I don't think you are asking for what you need.

Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

ilayaraja.ajsquare
Starting Member

8 Posts

Posted - 2010-09-27 : 05:36:14
Create QuoteOtherFeesSettings
(
QuotesOtherFeesSettingsID int identity(1,1),
Condition varchar(300)
)

SELECT [QuotesOtherFeesSettingsID]
,[Condition]
FROM [DealerSaas].[dbo].[QuoteOtherFeesSettings]
GO

condition column data will like the below
--------------------------------------------
i.Make = 2 And i.Model = 57 Or i.Location = 11
i.Make = 21 or i.Model = 57 Or i.Location = 11
i.Make = 21 or i.Model = 57 Or i.Location = 11 and i.year=2010

--------------------------------------------
declare @make varchar(max);
declare @model varchar(max);
declare @location varchar(max);

declare @sql varchar(max);
declare @quoteid varchar(max);
declare @cou int;
SET @location='10';
SET @model='57';
SET @make='21';

i want to replace the condition with the above value and by that condition i want to display the record

select (replace((REPlACE((REPLACE(condition,'i.make',@make)),'i.Model',@model)),'i.location',@location)) as 'temp' from QuoteOtherFeesSettings where QuotesOtherFeesSettingsID=11

and exists( CONVERT(varchar,(replace((REPlACE((REPLACE(condition,'i.make',@make)),'i.Model',@model)),'i.location',@location))))
Go to Top of Page
   

- Advertisement -