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.
Author |
Topic |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-12-15 : 07:56:56
|
JASON writes "Is it possible to loo =k upb a value in a table and use it as a define command?e.g. define name = (select a.namefrom namewhere order = 1)select * from surnamewhere a.name = &name;commit;" |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-12-15 : 08:01:48
|
[code]Declare @name varchar(8000)select @name = a.namefrom name awhere order = 1select * from surname awhere a.name = @name;[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-12-15 : 10:14:32
|
1 Make sure that the query returns single value2 You can also useselect * from surname awhere a.name in (select namefrom name awhere order = 1)MadhivananFailing to plan is Planning to fail |
|
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2006-12-15 : 11:03:22
|
Better still use a joinselect S.*from surname Sinner join name N on N.name = S.namewhere N.order = 1 |
|
|
|
|
|