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 |
direrayne
Starting Member
30 Posts |
Posted - 2011-01-31 : 10:19:09
|
I have a table that i need to replicate data in certain rows.example:ship code class targetcarnival 3 4 20navigator 2 3 20canival 6 7 NULLBecause of the number of rows and the number of ships i need to write a code that will find a ship and taget then find the emtpy targets and full them in dynamically. |
|
Jim Beam
Posting Yak Master
137 Posts |
Posted - 2011-02-01 : 14:54:24
|
This is just a start, as I've got not one, but TWO bits of bad news for ya....1) I'm in the process of learning myself (yeah, I know my status reads "Master", just don't believe everything you read!), but want to try;2) You don't mention what values the target field needs to have, as I imagine they will differ between the good ships Navigator and 'Carnival', and even when you do, that will need more skill in 'When...Then' clauses than I currently have.That said, best of luck to you, and here we go...@ship@targetUpdate YourTableNameHereSet Target = 'YourDesiredTargetValueHere'Where YourTableNameHere.Target is NullAnd YourTableNameHere.Ship = @shipAnd YourTableNameHere.Target = @target |
 |
|
jcelko
Esteemed SQL Purist
547 Posts |
Posted - 2011-02-01 : 15:52:44
|
"A problem well stated is a problem half solved." -- Charles F. KetteringPlease post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. If you know how, follow ISO-11179 data element naming conventions and formatting rules. Temporal data should use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. Sample data is also a good idea, along with clear specifications. It is very hard to debug code when you do not let us see it. If you want to learn how to ask a question on a Newsgroup, look at: http://www.catb.org/~esr/faqs/smart-questions.html--CELKO--Books in Celko Series for Morgan-Kaufmann PublishingAnalytics and OLAP in SQLData and Databases: Concepts in Practice Data, Measurements and Standards in SQLSQL for SmartiesSQL Programming Style SQL Puzzles and Answers Thinking in SetsTrees and Hierarchies in SQL |
 |
|
|
|
|
|
|