[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More
Experts Exchange Solution brought to you by
"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.
-- Create a table Variable
DECLARE @myTable TABLE (
-- add some records to @myTable
Insert into @myTable (FirstName,Lastname) values ('John','Smith')
Insert into @myTable (FirstName,Lastname) values ('Jane','Doe')
Insert into @myTable (FirstName,Lastname) values ('Homer','Simpson')
-- Query Table Variable
Select * from @myTable
Open in new window
SELECT col1,col2 FROM table1
SELECT col1,col2 FROM table2
Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.
IF @YEAR ='2013'
SELECT col1,col2 FROM xx_2013
IF @YEAR ='2014'
SELECT col1,col2 FROM xx_2014
DECLARE @sql2 as nvarchar(max)
declare @tblName as varchar(50)
Select @sql2 ='select 1 from ' + @tblName
EXECUTE sp_executesql @sql2
Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.