Template parameters

  • Comments posted to this topic are about the item Template parameters

  • I never use those. Great question though.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • This was removed by the editor as SPAM

  • I've created several templates for my own use and find them to be great time-savers. They're good for standardized processes you run that involves multiple steps where you just change out a few parameters, but the task isn't run frequently enough to rise to the level of a stored procedure. They're another good tool to have in the toolbox.

  • I have never heard of templates so I pulled found out how to access them and pulled up the first one for aggregates. Here is the part from the create:

    CREATE AGGREGATE <aggregate_name, sysname, sample_aggregate>(@<parameter_name, sysname, parameter1> <parameter_type, sysname, nvarchar(4000)>)

    RETURNS <return_type, sysname, nvarchar(4000)>

    EXTERNAL NAME <assembly_name, sysname, sample_assembly>.<clr_type_name, sysname, sample_clr_name>

    GO

    To me this says that the data type is the last item in the list so I picked that. Seems like there is some inconsistency in how the parameters are done.

  • I think I would have put this one under a different category. I don't know what this has to do with T-SQL. I still managed to get it right though.

    Tony
    ------------------------------------
    Are you suggesting coconuts migrate?

  • I wasn't 100% sure but, <name, type, default> seemed logical since that is the way variables/parameters are declared. Nice question.

    Aigle de Guerre!

  • Thanks for the question. Good one to end the week on.



    Everything is awesome!

  • Meow Now (10/24/2014)


    I wasn't 100% sure but, <name, type, default> seemed logical since that is the way variables/parameters are declared. Nice question.

    That was my thinking, too. Thanks, Steve. Enjoy London!

  • Thank you for the post, Steve, interesting one.

    I used this before and i have created my own templates for some set of specific work which i use them.

    ww; Raghu
    --
    The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.

  • tom.w.brannon (10/24/2014)


    I have never heard of templates so I pulled found out how to access them and pulled up the first one for aggregates. Here is the part from the create:

    CREATE AGGREGATE <aggregate_name, sysname, sample_aggregate>(@<parameter_name, sysname, parameter1> <parameter_type, sysname, nvarchar(4000)>)

    RETURNS <return_type, sysname, nvarchar(4000)>

    EXTERNAL NAME <assembly_name, sysname, sample_assembly>.<clr_type_name, sysname, sample_clr_name>

    GO

    To me this says that the data type is the last item in the list so I picked that. Seems like there is some inconsistency in how the parameters are done.

    You were unlucky with the selection of the template you picked, and the parameter you looked at.

    <return_type, sysname, nvarchar(4000)>

    The template is for a function (Aggregate is a specific type of function). This place is where the data type of the returned value is specified. The name of this parameter is "return_type", and the data type is "sysname" (a specific datatype for builtin names, an alias for I think nvarchar(128).) The third value here is the default: "nvarchar(4000)" - this looks like a data type because it is used in a template in a place where you have to specify a data type.

    If you had looked at the "aggregate_name" parameter, or if you had used e.g. a template for SELECT (if that exists), you would not have had this confusion.

    Like I said - unlucky.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • Thanks for the easy question.

    I haven't used templates since the good old ones we had back in Sql 2000.

    ---------------
    Mel. 😎

  • Thanks for the explanation Hugo. At least I was trying to think the right way.

  • Nice one, thanks for spotting it.

    Iulian

  • stephen.long.1 (10/24/2014)


    Meow Now (10/24/2014)


    I wasn't 100% sure but, <name, type, default> seemed logical since that is the way variables/parameters are declared. Nice question.

    That was my thinking, too. Thanks, Steve. Enjoy London!

    +1, Never used this tool before, but that was a pretty logic thinking enough.

    Thanks & Best Regards,
    Hany Helmy
    SQL Server Database Consultant

Viewing 15 posts - 1 through 15 (of 19 total)

You must be logged in to reply to this topic. Login to reply