| Author |
Topic |
|
ramakanth_gupta
Starting Member
5 Posts |
Posted - 2004-09-25 : 03:04:39
|
| can i use a select statement within the insert statement if the result set of the select statement provides the necessary values for insert statement> i had used the sql statementinsert into t_cbs_err_log (job_id,calling_mdul_nm,err_cd,err_msg_txt)values (select * from temp1 where jobid=2)>i got an error saying Server: Msg 156, Level 15, State 1, Line 1Incorrect syntax near the keyword 'select'.Server: Msg 170, Level 15, State 1, Line 1Line 1: Incorrect syntax near ')'. |
|
|
mohdowais
Sheikh of Yak Knowledge
1456 Posts |
Posted - 2004-09-25 : 04:42:33
|
| You dont need the VALUES keyword when inserting rows using a SELECT statement. It is always safe to use named fields instead of * too. This should work, assuming you dont have any datatype mismatches.INSERT INTO t_cbs_err_log (job_id,calling_mdul_nm,err_cd,err_msg_txt) SELECT field1, field2, field3, field4 FROM table WHERE jobid = 2OS |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-09-25 : 06:01:15
|
| Errrmmmm ... I use SELECT * from INSERTs quite often:INSERT INTO MyTableSELECT *FROM SomeSourceTableWHERE Somethingthe idea is that if a column is added to MyTable then this process will break - just in case it gets overlooked by our fantastic Peer Review System ;-)Kristen |
 |
|
|
mohdowais
Sheikh of Yak Knowledge
1456 Posts |
Posted - 2004-09-25 : 13:24:50
|
lol Kristen...how cheeky is that? OS |
 |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-09-25 : 20:22:19
|
| Only use that when you need to though. We use it for our archiving because of our "fantastic Peer Review System". In the production system though, "*" is not ever allowed and gets people DBA slapped!MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
slacker
Posting Yak Master
115 Posts |
Posted - 2004-09-25 : 22:30:54
|
quote: Originally posted by derrickleggett Only use that when you need to though. We use it for our archiving because of our "fantastic Peer Review System". In the production system though, "*" is not ever allowed and gets people DBA slapped!MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA.
Where is this land of dba's that have a peer review system. |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-09-26 : 02:51:16
|
| We have three programmers [including me] (plus a university-leaver hanging around for a while before he gets a proper job!).All code written here is peer reviewed. Period.The cost saving over shipping something defective means its a no-brainer to budget for.Edit: And it means that House Style is enforced for newbies, saving on down-stream maintenance costs.Kristen |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-09-26 : 02:52:42
|
| "how cheeky is that"I just slipped in under the radar there ...Kristen |
 |
|
|
slacker
Posting Yak Master
115 Posts |
Posted - 2004-09-26 : 06:53:40
|
quote: Originally posted by Kristen "[i]how cheeky is that[i]"I just slipped in under the radar there ...Kristen
Im the only programmer at my company. And If I worked with you guys I would have been shot already... |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-09-26 : 09:29:51
|
to paraphrase our jedi yak master:learn you must. here stay you will. Go with the flow & have fun! Else fight the flow |
 |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-09-26 : 12:20:51
|
| All code here gets peer reviewed as well. We have over 40 developers, 4 DBA's, blah, blah, blah now also though. Gheesh...when I started two years ago, I was the only DBA and we only had like 15 developers.MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-09-26 : 12:53:46
|
at my job there's 8 of us. we all code. there is also peer review.4 of us do sql stuff. one is a dba.Go with the flow & have fun! Else fight the flow |
 |
|
|
elwoos
Master Smack Fu Yak Hacker
2052 Posts |
Posted - 2004-09-26 : 14:23:45
|
| DBA's, Developers, peer review?? What are they? We're lucky enough to have 4 "network admins" (I use the term very loosely) and that's your lot.steveSteve no function beer well without |
 |
|
|
slacker
Posting Yak Master
115 Posts |
Posted - 2004-09-26 : 19:01:28
|
quote: Originally posted by elwoos DBA's, Developers, peer review?? What are they? We're lucky enough to have 4 "network admins" (I use the term very loosely) and that's your lot.steveSteve no function beer well without
man you guys all work from medium size to large companies... network admin? hell here are my job titlesIT support,Software support ( internet explorer, ms-access ( eww ) ),DBA, ( LOL! I need to back something up before the db crashes ),IIS Administrator,dns administrator,mail administrator,asp.net programmer,T-SQL programmer,software troubleshooter ( including unix ),Yes man ( literally... Im a real bonified yes man ),studentIt would be great if i could specialize in just one thing... If I had to choose it would be T-Sql programming. Thats the thing I like the most. |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2004-09-27 : 00:14:22
|
you guys are really lucky, how do you implement a peer review without programmers biting your head off or giving you the evil eye? there should be a course on how to handle difficult co-workers |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-09-27 : 02:33:29
|
| "Im the only programmer at my company"Assuming that you have enough time to "start" the process, it can be done with one person (obviously not the same exact benefits of a second-pair-of-eyes, but.)Copy your code to a "separate" folder.Once a week, say, compare the "current" code to the "archive" code. You need a decent comparison tool for the job (we use DiffZilla from the Visual Slick Edit boys - how corny a name is that?!)Check that you are comfortable with each change you made to the code, with the benefit of hindsight. Probably best to do this on a Monday when the "newest" code is already a couple of days stale in your mind.Then copy the Current code to the Archive folders ready for next timeIf you don't find any bugs after a while then stop doing it and wait until there is a second developer in your team!"implement a peer review without programmers biting your head off"Well, firstly it isn't a big brother thing - nothing wrong with having pairs peer review each others work. Obviously a senior should perform some proportion of code review - mainly to check overall quality, and conformance to "house style" and the like.We do a small amount of code two-handed(!!) - i.e. two programmers sitting at one screen evolving a problem. I've read articles about coding shops where all code is written this way - no code review required, two people immediately up-to-speed with the code, and [apparently] a lower rate of bugs etc. Can't quite pursuade myself that we can afford that though!Given that I don't have a formal computing education, my thinking on this was gleaned from books by Microsofties like Steve Macguire and Steve McConnellKristen |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2004-09-27 : 02:41:26
|
| i've been struggling with this peer review thing. when programmers come to me and ask me why the server is soooooo slow. i advise them that i'll conduct some tests (profile, network, query tuning,etc). then when i hand them over the results and they see the adjustments, guess what they'll say... the application is too big already to modify. arrrggghhhh.....then they come back to me another day and ask me why the server is slowww...... (i'm whining here but how do you really have them listen and respond positively? whacking them on the head with a sql book is not an option) |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-09-27 : 04:13:31
|
| It helps if you are the boss <SmugG>Kristen |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-09-27 : 05:11:18
|
two programmers at one computer = pair programming.i've done it once for a day. nice experience. but you need to find two people that have different views of problems and "click ok" which is hard to find.Go with the flow & have fun! Else fight the flow |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2004-09-27 : 05:47:22
|
| I'm lucky in that my No. 2 has a completely different outlook in solving the problems we currently face. We are hampered by having two sets of visions (some, ermmm ... "heated discussion" occurs), but the composite result is much stronger than either of us could have written on our own IMHO.Kristen |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2004-09-27 : 07:43:06
|
| stop! i'm turning green with envy, i think i'll ask our programmers to become members here instead...atleast they'll "see" what things should and should not be done...what dya think guys? |
 |
|
|
Next Page
|