| Author |
Topic |
|
Sir_William
Starting Member
6 Posts |
Posted - 2011-11-18 : 00:14:31
|
| Perhaps I've missed it in my search, but I'm trying to find a way to view the SQL code of an import I did from Access.I created the database and table in Access, and after a painful line-by-line insert process, I decided to import it into SQL server 2008. I could not get the Excel spreadsheet to import for some reason.That said, I would like to view the code of that import...the INSERT statement(s) that went into populating the table with the data, etc.How do I accomplish this? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
Sir_William
Starting Member
6 Posts |
Posted - 2011-11-18 : 00:23:56
|
| Thank you for the prompt reply.However, you've just lost me. I'm extremely new to SQL, thus the reason for my post in this forum.Can you provide any additional guidance on how to implement and execute the generator provided. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2011-11-18 : 00:28:09
|
| Copy the entire code on the link I posted. Run it on your SQL Server by clicking execute. This saves the code as a stored procedure. Now you need to execute the stored procedure. It can be as simple as this: EXEC sp_generate_inserts 'YourTableName'Oh and make sure you do this in the database where your table exists.If you need more flexibility, see the examples in the comment header block of the code as Vyas provides lots of functionality with his generator.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/Subscribe to my blog |
 |
|
|
Sir_William
Starting Member
6 Posts |
Posted - 2011-11-18 : 01:00:12
|
| OK, I've copied the code and executed it. I'm getting errors.Here is the output:Using Master databaseChecking for the existence of this procedureProcedure already exists. So, dropping itMsg 2812, Level 16, State 62, Line 3Could not find stored procedure 'master.dbo.sp_MS_upd_sysobj_category'.Created the procedureMsg 2812, Level 16, State 62, Line 4Could not find stored procedure 'master.dbo.sp_MS_upd_sysobj_category'.Granting EXECUTE permission on sp_generate_inserts to all usersDoneWhen I run the EXEC sp_generate_inserts 'YourTableName' to generate the INSERT statements I get the following:Msg 537, Level 16, State 2, Procedure sp_generate_inserts, Line 331Invalid length parameter passed to the LEFT or SUBSTRING function.Msg 537, Level 16, State 2, Procedure sp_generate_inserts, Line 332Invalid length parameter passed to the LEFT or SUBSTRING function.Msg 50000, Level 16, State 1, Procedure sp_generate_inserts, Line 336No columns to select. There should at least be one column to generate the output |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
Sir_William
Starting Member
6 Posts |
Posted - 2011-11-18 : 01:09:27
|
| Nothing really to destroy....I've just created this database, and I've saved it off separately before departing on this adventure.I'm just looking for a way to view the INSERT statements from the data I've imported to the table from Access. |
 |
|
|
Sir_William
Starting Member
6 Posts |
Posted - 2011-11-18 : 01:24:34
|
| I found the error(s), and I've fixed my problem.I replaced 'master' with the correct name of my database, and all is well.Thank you for your help. I look forward to spending more time here learning more and more about SQL, etc.Cheers!BTW, Brett, no margaritas here....but I was able to pour a nice single malt over one ice cube... enjoy! |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
Sir_William
Starting Member
6 Posts |
Posted - 2011-11-18 : 02:01:04
|
| Touche'That said, this Glenlivet 21 does me well with a small 1" frozen drink cube (not really ice).It's made of some other material that you put in the freezer so as not to water down the drink. Pardon my Neanderthal ways, it's how I roll... ;) |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|