• saravanakumar.G (8/28/2013)


    Hi,

    I have tried and created one sp which will get the table name as input and will return all the records in that table. I will map this sp in the SSMS keyboard shortcut (just like Alt + F1 to return the table structure) so that i can use this shortcut to get the records from that table instead of writing some thing like SELECT * FROM tablename. this sp works fine and helped me a lot. however, if the table is belong to a schema then we have to pass the table name along with schema like schema.tablename. In this case, the sp is failing. If i put single quotes between the table name like 'schema.tablename' it is working fine. But is there any option to tweak the sp so that we dont have to pass the table name in quotes.

    The sp is

    create PROC [dbo].[sp_getrecords]

    (

    @TableName varchar(4000)

    )

    AS

    exec('select * from '+@TableName+'')

    You don't need a proc for this. If you map "SELECT * FROM " in the keyboard shortcut it will work as you want.

    The SQL Guy @ blogspot[/url]

    @SeanPearceSQL

    About Me[/url]