Generating crud scripts from table def?

ChrisDuncanMnxChrisDuncanMnx Posts: 7
edited January 30, 2012 4:03AM in SQL Prompt Previous Versions
Hey, guys.

I'm new to the Redgate tools and quite enjoying the experience. I just wrote a batch of standard crud procs for a handful of tables and found the auto population of the insert statement to be time saving.

I was wondering if anyone has wired up the tool and / or snippets in such a way that I could point at a table and have it auto generate the create / update / delete procs from the table def.

Forgive the clueless question if this isn't how Sql Prompt works. That said, I figure if this sort of thing is possible I'm surely not the first person to think of it.

Thanks!
Christopher Duncan
Midnite Express

Comments

  • Eddie DEddie D Posts: 1,802 Rose Gold 5
    Thank you for your post into the forum.

    Excellent news that you are enjoying using SQL Prompt.

    You can create and add your snippets to use. Please vist this Web Page In the Learning SQL Prompt section, expand the topic "Speeding up your Queries" and take a look at the "Inserting snippets" and "Managing Snippets". This will help you create your own snippets to achieve your goal of automatically create / update and delete your Stored procedures.

    Many Thanks
    Eddie
    Eddie Davis
    Senior Product Support Engineer
    Redgate Software Ltd
    Email: support@red-gate.com
  • Hi, Eddie.

    Thanks for the reply. I've looked at both of the pages you recommended but there's not much detail on either one.

    In order for the snippet system to be able to automatically generate the create, update and delete procs based on a given table, there needs to be a way for it to take a reference to the table name, get the list of its column names and data types, and then use that in the generated code to populate the procs.

    Are there other sources of information that I should be referencing to understand how I accomplish this?

    Thanks,
    Christopher Duncan
    Midnite Express
  • Have you seen the SSMS Tools Pack?

    http://www.ssmstoolspack.com/Features?f=12

    This has the ability to auto-generate CRUD Sprocs.

    Hope this helps,

    Justin
    Justin Caldicott
    Developer
    Redgate Software Ltd
  • Hey, Justin.

    Very cool, thanks for the link! Is this your stuff?
    Christopher Duncan
    Midnite Express
  • Alas no!

    I'd be interested to hear if it solves your problem sufficiently.

    Thanks,

    Justin
    Justin Caldicott
    Developer
    Redgate Software Ltd
  • You still get bonus points for coming up with what looks like a great addition. Take two cookies out of petty cash. ;-)

    By the way, I have the Redgate tools, which means Sql Prompt is installed. Do you happen to know if there's a conflict between the two? Seems like they do similar things so I don't know if they'll get into a cat fight over every character I type.
    Christopher Duncan
    Midnite Express
  • Okay, I just installed it and gave it a quick run on the crud stuff (and apparently that's just scratching the surface).

    Bovine deity.

    Man, this would have saved me a ton of work the past week. Thanks!
    Christopher Duncan
    Midnite Express
  • Glad to hear it helped!

    Justin
    Justin Caldicott
    Developer
    Redgate Software Ltd
  • Not to plug the opposition (Not really) :roll:

    Have you looked at CodeSmith (www.CodeSmthTools.Com) , you can set up extremely comprehensive templates that generate CRUD and lots of other code . There samples show you how, even to using full blown ORM's like NHibernate . Along with their own PLINQO ones

    You can also Use T4 in VS to generate stuff , but it takes a bit more effort.

    ALSO again there are INSERT DELETE and UPDATE templates in Sql Management Studio

    Cheers

    Mike
Sign In or Register to comment.