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 |
stoolpidgeon
Starting Member
28 Posts |
Posted - 2013-06-27 : 06:21:28
|
Is the following logic permissible in SQL Server?INSERT INTO tblWorkloads (Job_Desc ,Association ,Task_Main ,Task_Sub ,For_With ,Status ,Start_Date ,Req_Date ,Employee) VALUES (txtJobDesc' ,islAssociation' ,islTaskMain' ,islTaskSub',islForWith' ,0 ,dateStartDate_Hidden' ,dateReqDate_Hidden' ,Employee') case 'SubCat' when not '' then (insert into tblbenchmarks ( Spreadsheet_Data, Invoice_Dates, Product_Codes, Descriptions, Pack_Sizes, Volumes, Unit_Prices, Rebate_Info, JobID, BenchmarkID) values ( 'cboxSpreadsheetData', 'cboxInvoiceDates', 'cboxProductCodes', 'cboxDescriptions', 'cboxPackSizes', 'cboxVolumes', 'cboxPrices', 'cboxRebateInfo' 'JobID', newid() ) end |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-06-27 : 06:45:46
|
nope. it has few syntax issueswhat are 'txtJobDesc' ,'islAssociation','islTaskMain','islTaskSub',...Are they table columns or string constant values? which table have them? also where does SubCat column come from?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
stoolpidgeon
Starting Member
28 Posts |
Posted - 2013-06-27 : 06:47:50
|
The column names etc are fine, and the table names. The question really is whether I can use a second Insert statement conditional on an input field being populated.i.e. When the SubCat field on a form is populated I want the second Insert statement to execute. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-06-27 : 06:59:52
|
quote: Originally posted by stoolpidgeon The column names etc are fine, and the table names. The question really is whether I can use a second Insert statement conditional on an input field being populated.i.e. When the SubCat field on a form is populated I want the second Insert statement to execute.
you cant use form fields directly like this in sql.either you need to form the dynamic sql string in your front end language using form field appending it to static part of the queryor you need to create a procedure in sql with field value sent as a parameter. then in procedure, check using IF whether value of parameter is not '' and do the INSERT.Which front end language you're using?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|
|
|