Trying to Determine What a Declared Variable Will Return

gdunn59
gdunn59 used Ask the Experts™
on
I was given this scenario, and need to determine what a specific declared variable would return:

Table:  Employees
ID int not null
F_Name varchar(50) not null
L_Name varchar(100) not null

DECLARE @ColumnName varchar(255)
SET @ColumnName = "

SET @ColumnName = 
         (
              SELECT MIN(QUOTENAME(COLUMN_NAME))
                    FROM Information_Schema.Columns
                      WHERE Table_Name = "Employees"
                          AND Data_Type IN ('char','varchar','nchar','nvarchar')
         )


Will it return ID, F_Name, L_Name or will it return an Error?

Thanks,

gdunn59

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
This is a quiz question and has been reported.

Author

Commented:
Tony,

I am 56 years old and I am not in school.  I just came across a workbook that I had years ago from a previous job that my boss supplied to me.  I was going over some of the SQL Statements in this book and trying to familiarize myself with more advanced SQL Statements that I was not familiar with.
Scott PletcherSenior DBA
Most Valuable Expert 2018
Top Expert 2014

Commented:
Can't you install a free version of SQL Express and just run the statement and see what it returns?

Author

Commented:
Scott,

I did run it and it executes fine with no errors, but it doesn't show the results.

How can I see the results?

Thanks,

gdunn59
The quiz question is #22 at:
http://forum.iwethey.org/forum/post/400999/

You obtain the answer by the following code:
SELECT @ColumnName

Open in new window


But you should not use EE to answer your questions for you.  Rather ask how to come up with the answers yourself.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial