I am afraid of 'SQL Injection' problems, but don't know a good way to go about this with out using dynamic SQL.
Here's what I need. I am creating a "data dictionary" of sorts. The person who requested this, requested that we put a link within the report (SSRS '05) to another report showing details of the "look up table" for each column that has a look up code.
Of course I do all my work within the SQL query so that's why I'm on this forum...I wouldn't dare do this in the reporting side.
So, say you have the Employees table -
Within this table are lookup values for
Cost Centers
Departments
Supervisors
--"Cost Centers" & "Departments"
have column names of 'Abbrv', 'Name', 'Description'
--But "Supervisors"
has column names of 'Code', 'Name', 'Description'
I need all three columns of each table, but it depends on the table as to which columns it possesses. And there are too many look up tables in the system to do a case statement for which table has which columns.
I've looked all over and tried many different things.
And like I said I still am afraid of what I keep hearing about SQL Injections...as this report that will utilize whatever code (Procedure) I come up with will be accessable on our Report Manager.
Anybody got an clever suggestions?
I tried this to get the column names for the given table:
Works great for getting the column names...but don't know where to go from here. *sigh*
Any help would be so greatly appreciated.
Thank you,
RSBLaird
Here's what I need. I am creating a "data dictionary" of sorts. The person who requested this, requested that we put a link within the report (SSRS '05) to another report showing details of the "look up table" for each column that has a look up code.
Of course I do all my work within the SQL query so that's why I'm on this forum...I wouldn't dare do this in the reporting side.
So, say you have the Employees table -
Within this table are lookup values for
Cost Centers
Departments
Supervisors
--"Cost Centers" & "Departments"
have column names of 'Abbrv', 'Name', 'Description'
--But "Supervisors"
has column names of 'Code', 'Name', 'Description'
I need all three columns of each table, but it depends on the table as to which columns it possesses. And there are too many look up tables in the system to do a case statement for which table has which columns.
I've looked all over and tried many different things.
And like I said I still am afraid of what I keep hearing about SQL Injections...as this report that will utilize whatever code (Procedure) I come up with will be accessable on our Report Manager.
Anybody got an clever suggestions?
I tried this to get the column names for the given table:
Code:
--drop table #test
declare @TableName varchar(200)
SET @TableName = 'EMPLOYEES'
--get column names for particualr table
SELECT name
INTO #Test
FROM sys.columns
WHERE [object_id] = OBJECT_ID(@TableName)
AND Name in ('Code','Abbreviation','Name','Description');
SELECT DISTINCT ColumnName = substring((SELECT DISTINCT ( ', ' + [Name] )
FROM #Test
FOR XML PATH( '' )),3,1000)
Any help would be so greatly appreciated.
Thank you,
RSBLaird