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 - 2005-08-12 : 08:10:03
|
| Bob writes "Your FAQ asks an intersting question:Why doesn't SELECT @columns FROM @tablname work?No answer is provided however.I need to write a stored procedure the passes in a fieldname, retrives next key type int data from that field, increments the field, and returns the NextKey.Would be nice if something like this worked:DECLARE @iNext INTSELECT @iNext = SELECT @columnName FROM Next_Keys WHERE ID = 1SELECT @iNext = @iNext +1UPDATE Next_Keys Set @columnName = @iNext WHERE ID = 1RETURN @iNextSQL Server 2000 - Win Server 2003Editing SP from VS2005TSQL newbe writing first sp" |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2005-08-12 : 08:11:27
|
| Well, when I read the FAQ I find links to three articles on Dynamic SQL that explain how to do what you're looking for. They're about 5 lines down from the question you posted. |
 |
|
|
|
|
|