March 12, 2019 at 6:43 am
create table #ListOfUsers
(
[FULLNAME] varchar(200),
varchar(100),
[ACCOUNT_NAME] varchar(200),
[ACCOUNT_NAME_WITH_DOMAIN] varchar(200),
[DEPARTMENT] varchar(200),
[TITLE] varchar(200)
,[AD_GROUP] varchar(200)
March 12, 2019 at 12:26 pm
A view can only consist of a single SELECT statement. You cannot create tables, declare, open, close, deallocate, or fetch from cursors, execute dynamic sql, or declare variables. You may want to make this a stored procedure instead.
In any case, you may want to look at getting rid of the CURSOR.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
March 13, 2019 at 6:40 am
You are correct, I know you can't declare variables in a view, I guess I should have said how to make this as a function or a SP and create a view based on that.
To get the result I needed, I created a job to insert the data into a table. So I am good.
As for using the cursor, can you please tell me why I need to get rid of it? I am getting the LDAP group names and looping through to get a list of users for each AD group. If you have a better way of doing it, please feel free to share an example. Thank you.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply