You can get the table name from the program.
Like the following code:
Create Procedure [dbo].[sp_SelectAll] @BankName nvarchar(50) As Begin Select * From @BankName End
This is an error code.
Is there another way?
you can do it like:
exec ('select * from' + @BankName)
but it is not a good practice to use this.
You can learn more about dynamic sql from:
http://www.mssqltips.com/tip.asp?tip=1160
http://www.sqlteam.com/article/introduction-to-dynamic-sql-part-1
Tables cannot be parameterized. You have to write dynamic sql ie generate sql strings and execute it with exec.
try it
Create Procedure [dbo].[sp_SelectAll] @BankName nvarchar(50) As Begin EXEC('Select * from '+ @BankName) End
You need to work with dynamic SQL to do this correctly.
dynamic SQL
Source: https://habr.com/ru/post/1339784/More articles:How to use bouncy lock API in J2ME using eclipse? - javaXQuery LIKE statement (starts with) - xmlWhat is the fastest way to convert image to black and black in C #? - c #Why is $ (": select") the focus not working, but $ (": input"). Does the focus work? - jqueryLog in with facebook login - iphoneHow can I simulate a swipe gesture programmatically? - iosHow to run an application running SYSTEM? - cPointer and proper expression evaluation in C - cThe validation start date must be less than the end date in Yii - dateWPF event management for users - eventsAll Articles