Hi All,
I have 1 query in sql server.
DECLARE @sqlWhere VARCHAR(MAX)
SET @sqlWhere = 'flg_active = 1 order by CreatedDate'
Select * from TableName1 where @sqlWhere
Is it possible with out dynamic SQL.
Thanks,
Jitendra Patel
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Pravin MorePosted Jan 23, 2012, 11:39 PM
i dont think writing query in string and then exec will make delay compare to normal query.performance will be same.
Jitendra PatelPosted Jan 23, 2012, 8:57 AM
if there are not any other option then I will continue with exec (dynamic sql)
Thanks for co-operate.
Jignesh TrivediPosted Jan 23, 2012, 7:55 AM
that is correct you will retrive 6500000 rows.
but i think when you use exec, it will not effect ur performance.
Jitendra PatelPosted Jan 23, 2012, 7:04 AM
I am using sql server 2008.
I have 6500000 records and when I am useing dynamic sql then it's performance is very slow.
Jignesh TrivediPosted Jan 23, 2012, 6:05 AM
is there any restriction not use dynamic sql.
are u using which technology> i.e. pure SQL or ADO.net?
Jitendra PatelPosted Jan 23, 2012, 4:42 AM
it's a correct answer but I don't use dynamic Sql
Pravin MorePosted Jan 23, 2012, 4:11 AM
you need to give it like.............
DECLARE @sqlWhere VARCHAR(MAX)
DECLARE @qry VARCHAR(MAX)
SET @sqlWhere = 'flg_active = 1 order by CreatedDate'
set @qry='Select * from TableName1 where'+ @sqlWhere
exec(@qry)
Thanks,
Pravin.