Click here to Skip to main content
15,899,026 members
Home / Discussions / Database
   

Database

 
QuestionEntity Framework and Default Values [answered] Pin
Pascal Ganaye21-Jul-11 6:33
Pascal Ganaye21-Jul-11 6:33 
AnswerRe: Entity Framework and Default Values [answer] Pin
Pascal Ganaye21-Jul-11 22:05
Pascal Ganaye21-Jul-11 22:05 
QuestionHow to do a select statement from two or more tables? Pin
eight20-Jul-11 23:27
eight20-Jul-11 23:27 
AnswerRe: How to do a select statement from two or more tables? Pin
Blue_Boy20-Jul-11 23:43
Blue_Boy20-Jul-11 23:43 
GeneralRe: How to do a select statement from two or more tables? Pin
eight20-Jul-11 23:51
eight20-Jul-11 23:51 
GeneralRe: How to do a select statement from two or more tables? Pin
Blue_Boy21-Jul-11 0:58
Blue_Boy21-Jul-11 0:58 
AnswerRe: How to do a select statement from two or more tables? Pin
Niladri_Biswas24-Jul-11 22:26
Niladri_Biswas24-Jul-11 22:26 
General:-\ Select Pin
velmahesh20-Jul-11 18:22
velmahesh20-Jul-11 18:22 
AnswerRe: What is Buffer Pool in SqlServer? Pin
Mycroft Holmes20-Jul-11 20:51
professionalMycroft Holmes20-Jul-11 20:51 
AnswerRe: What is Buffer Pool in SqlServer? Pin
Blue_Boy20-Jul-11 21:25
Blue_Boy20-Jul-11 21:25 
GeneralRe: What is Buffer Pool in SqlServer? Pin
Shameel21-Jul-11 2:29
professionalShameel21-Jul-11 2:29 
GeneralRe: What is Buffer Pool in SqlServer? Pin
Blue_Boy21-Jul-11 2:44
Blue_Boy21-Jul-11 2:44 
AnswerRe: What is Buffer Pool in SqlServer? Pin
PIEBALDconsult21-Jul-11 2:45
mvePIEBALDconsult21-Jul-11 2:45 
QuestionSSRS 2005 Sub report issue (newbie) Pin
Paul E Davies19-Jul-11 1:07
Paul E Davies19-Jul-11 1:07 
AnswerRe: SSRS 2005 Sub report issue (newbie) Pin
Paul E Davies21-Jul-11 0:27
Paul E Davies21-Jul-11 0:27 
QuestionSQL Syntax Issue Pin
Frank Lepkowski18-Jul-11 3:04
Frank Lepkowski18-Jul-11 3:04 
AnswerRe: SQL Syntax Issue Pin
Tim Carmichael18-Jul-11 3:13
Tim Carmichael18-Jul-11 3:13 
AnswerRe: SQL Syntax Issue Pin
AnnieMacD18-Jul-11 3:38
AnnieMacD18-Jul-11 3:38 
QuestionDynamic Query Question Pin
Kevin Marois14-Jul-11 19:01
professionalKevin Marois14-Jul-11 19:01 
AnswerRe: Dynamic Query Question Pin
Blue_Boy14-Jul-11 20:54
Blue_Boy14-Jul-11 20:54 
GeneralRe: Dynamic Query Question Pin
Kevin Marois15-Jul-11 5:34
professionalKevin Marois15-Jul-11 5:34 
GeneralRe: Dynamic Query Question Pin
smcnulty200015-Jul-11 22:31
smcnulty200015-Jul-11 22:31 
Absolutely.

Dasblinkenlight's solution is a nice one to the problem, BTW.

I normally build a temp table and just run the data into that. Using an insert or an update.

I know it seems (both suggested solutions) like a lot of overhead to get one piece of data out but that's really what it takes.

create table #Value (
val int 
)

set @command = 'insert into #value (val) SELECT top 1 voterid FROM tblCamp_CT WHERE ' +@Query

 exec(@command) 

set @voter_id=(select top 1 val from #Value)
delete #Value  


Like that.

You could also research sp_executesql for your project.

this works, for example:

declare @voter_id int , @query varchar(max), @command nvarchar(4000) 
,@parm nvarchar(20) 
 
set @query='1=1'

SET @Command = 'SELECT top 1 @voter_id = voterid FROM tblCamp_CT WHERE ' + @Query
 
 
set @parm ='@voter_id int output '

  exec sp_executesql @command,@parm ,@voter_id out    
 
 select  @voter_id test 


As you can see the sp_executesql gives you another option.
Some of this depends on what your personal flavor is toward a given solution.
_____________________________
Give a man a mug, he drinks for a day. Teach a man to mug...

AnswerRe: Dynamic Query Question Pin
smcnulty200014-Jul-11 21:53
smcnulty200014-Jul-11 21:53 
AnswerRe: Dynamic Query Question Pin
dasblinkenlight15-Jul-11 17:00
dasblinkenlight15-Jul-11 17:00 
AnswerRe: Dynamic Query Question Pin
PIEBALDconsult16-Jul-11 4:27
mvePIEBALDconsult16-Jul-11 4:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.