Search
 
SCRIPT & CODE EXAMPLE
 

SQL

How should I pass a table name into a stored proc?

SELECT @ActualTableName = QUOTENAME( TABLE_NAME )
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = @PassedTableName

DECLARE @sql AS NVARCHAR(MAX)
--SELECT @sql = 'SELECT COUNT(*) FROM [' + @ActualTableName + '];'

-- changed to this
SELECT @sql = 'SELECT COUNT(*) FROM ' + @ActualTableName + ';'

EXEC(@SQL)
Comment

PREVIOUS NEXT
Code Example
Sql :: apikey in pl sql 
Sql :: grouping function in mysql 
Sql :: having all mysql 
Sql :: How Much Space is PL/Scope Data Using? 
Sql :: Laravel SQLSTATE[HY093] with array query 
Sql :: postgres audit table 
Sql :: plsql to generate all combinations of specified number of characters in string 
Sql :: c# execute transact sql 
Sql :: get created time of database psql 8 
Sql :: mysql beautify output 
Sql :: USING THE NOT CONDITION IN SQL 
Sql :: tsql table column constraint must be uppercase 
Sql :: Aktor yang pernah terlibat lebih dari 3 film di sql 
Sql :: postgres regex word boundary 
Sql :: first row in deluge 
Sql :: bidirectional outer join sql 
Sql :: nth max in my sql 
Sql :: provide hardcoded value in the mysql query 
Sql :: sql grant 
Sql :: how to create a table from another table in sql derby 
Sql :: get employees if not contains in sql 
Sql :: multiple select into sql oracle 
Sql :: oarcale list objects 
Sql :: mysqli count down 
Sql :: select from where 
Sql :: ejecutar script sql 
Sql :: sql select upcoming birthdays 
Sql :: sql queries questions 
Sql :: what is rownum in oracle 
Sql :: stored procedure vs view 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =