This is probably a simple question, and I'm sorry if it's not worded super clearly. If I could word this more clearly... I'd probably be able to find the answer online.
What I want to do, is be able to write down the table name only one time at the top of my SQL, and let the system carry that through the rest of my SQL. I am essentially doing it with individual values like mindate but can't get it to work for the whole table.
This works:
Use DB
declare @mindate int
select @mindate = min(dateid) from dbo.Mytable
print @mindate
This does not work (Obviously)
Use DB
set dbo.Mytable = TB
declare @mindate int
select @mindate = min(dateid) from TB
print @mindate
I tried different things, but they're not even worth posting and clumping up this question with. Can't figure this one out on my own.