Awright. Puz... problem #2. Nothing with dates 
Every once in a while someone asks about SQL data dumping tool. Not DTS or bcp out/in (...damnit). Something like mysqldump -d, capable of generating buncha INSERT statements for each table we specify. Such tool would be quite handy in some situations so...
Write stored procedure that dumps single table as SQL code.
Prototype and output
Let's do it minimalistic. Only one input argument:
adm_dumpTable_<yournicknamehere>( @table_name sysname )
... and one returned result set with two columns:
1. lineNo int
2. SQLCode nvarchar(4000)
Things to take care about
Generated SQL code must be perfectly valid - string data properly quoted, NULLs written as "NULL" etc.
Anything above that is up to you. Imagine all possible scenarios during which generated code may fail or INSERT different values...
Things to ignore
BLOB/CLOB columns - text, ntext, image.
varchar size limit. We don't have tables with 250+ columns, right?
Timestamp columns.
Views and system tables - dump should work only on user tables, for obvious reasons.
Proposed testing
Create blank database. Choose one table, for example table Northwind.db
rders. Generate it's script (with primary key, but no foreign keys!) and dump data from that table with stored procedure from above. Run both script and code in blank DB. Etc etc.
Rules and scoring
Unlike previous problem, this one is hard to measure with stopwatch or something. Speed is irrelevant within reasonable margins - any code that doesn't suffer from excessive cursoritis is good to go. Let's do scoring this way:
- for each feature implemented/supported: +3 points. Example: identity inserts
- for each bug found: -1 point. Example: script crashes on varchar(N) column containing "O'Neill"
I know this scoring schema isn't perfect... but will make things competitive.
Regarding restrictions, you may not use anything outside database or call extended stored procedures.
Same as before - don't show any code until next Friday (Jan 27th).
If something isn't clear - just ask.
------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
![[banghead] [banghead] [banghead]](/data/assets/smilies/banghead.gif)
Every once in a while someone asks about SQL data dumping tool. Not DTS or bcp out/in (...damnit). Something like mysqldump -d, capable of generating buncha INSERT statements for each table we specify. Such tool would be quite handy in some situations so...
Write stored procedure that dumps single table as SQL code.
Prototype and output
Let's do it minimalistic. Only one input argument:
adm_dumpTable_<yournicknamehere>( @table_name sysname )
... and one returned result set with two columns:
1. lineNo int
2. SQLCode nvarchar(4000)
Things to take care about
Generated SQL code must be perfectly valid - string data properly quoted, NULLs written as "NULL" etc.
Anything above that is up to you. Imagine all possible scenarios during which generated code may fail or INSERT different values...
Things to ignore
BLOB/CLOB columns - text, ntext, image.
varchar size limit. We don't have tables with 250+ columns, right?
Timestamp columns.
Views and system tables - dump should work only on user tables, for obvious reasons.
Proposed testing
Create blank database. Choose one table, for example table Northwind.db
Rules and scoring
Unlike previous problem, this one is hard to measure with stopwatch or something. Speed is irrelevant within reasonable margins - any code that doesn't suffer from excessive cursoritis is good to go. Let's do scoring this way:
- for each feature implemented/supported: +3 points. Example: identity inserts
- for each bug found: -1 point. Example: script crashes on varchar(N) column containing "O'Neill"
I know this scoring schema isn't perfect... but will make things competitive.
Regarding restrictions, you may not use anything outside database or call extended stored procedures.
Same as before - don't show any code until next Friday (Jan 27th).
If something isn't clear - just ask.
------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
![[banghead] [banghead] [banghead]](/data/assets/smilies/banghead.gif)