Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
avarndel
Starting Member
5 Posts |
Posted - 2007-08-08 : 15:34:01
|
| I'm New to SQL and I'm trying to do something which sounds easy, but seems to be complicated to code.I have two tables. Table A has a column called ColName and isViewableTable B has columns called role, source, etc.I want to check in Table A where ColName = Table B column and is Viewable.This is as far as I got so far. Your help will be much appreciated.Set nocount ondeclare @viewColumns VarChar(15), @budgetColumns as VarChar(15), @Columns as VarChar(15), @count int , @count2 int,@count3 intSELECT @count=1SELECT @count2=1SELECT @viewColumns (Select FeeColName from xFeeColumns where IsViewable='1')SELECT @budgetColumns (Select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME ='xBudgetNodeFees')if @viewColumns[@count] = @budgetColumns[@count]begin select @columns = @viewColumns Select @count3= @count3+1end |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2007-08-08 : 16:35:16
|
Not sure I get what your desired result should be, does this work? SELECT *FROM TableAINNER JOIN TableB ON TableA.ColName = TableB.[Column]WHERE TableB.IsViewable = 1 |
 |
|
|
avarndel
Starting Member
5 Posts |
Posted - 2007-08-09 : 07:32:31
|
| That means I have to check each column in Budget to see if it is viewable. Is that correct? Is there a way I can check all of them at once? I'm trying to get data from xBudgetNodeFees where in xFeeColumns indicate that it is viewable.SELECT * FROM xBudgetNodeFeesINNER JOIN xFeeColumns ON xBudgetNodeFees.ColName=xFeeColumns.[FeeColName]WHERE xFeeColumns.IsViewable = '1' |
 |
|
|
|
|
|