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-01-06 : 08:35:05
|
| dfetrow410@hotmail.com writes "I am building a form builder that allows you to make dynamic forms. I amtrying to make pre-selected questions. One of them is: Choose the Storenearest you.So I add the question in the first insert and get the identity to add in theFormCreator_QuestionOptions in the second table. Here is the part I can'tget. The store names are in the franchisees table and I need to copy theminto the FormCreator_QuestionOptions and put the declared values in to withthe same insert/select statement.declare @QuestionIDas int declare @ViewOrder as int declare @OptionTextboxMode as nvarcharINSERT INTO FormCreator_Question (Q_Name )VALUES (@Q_Name)set @QuestionID= @@identityset @ViewOrder = 999set @OptionTextboxMode = 'TextBoxMode.SingleLine'INSERT FormCreator_QuestionOptions (QuestionID, OptionText, ViewOrder,OptionTextboxMode)SELECT REPLACE(REPLACE(UnitName, '/ Store', ''), '/ SRU', '') + ', ' +State AS OptionTextFROM franchiseesWHERE (Ctry = 'US')ORDER BY State-- Dave" |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-01-06 : 08:55:35
|
just add the variables to the selectINSERT FormCreator_QuestionOptions (QuestionID, OptionText, ViewOrder,OptionTextboxMode)SELECT @QuestionID, REPLACE(REPLACE(UnitName, '/ Store', ''), '/ SRU', '') + ', ' +State AS OptionText, @ViewOrder, @OptionTextboxModeFROM franchiseesWHERE (Ctry = 'US')ORDER BY StateGo with the flow & have fun! Else fight the flow |
 |
|
|
|
|
|
|
|