<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Retrieve Dataset from SQL Server in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Retrieve-Dataset-from-SQL-Server/m-p/636035#M21350</link>
    <description>&lt;P&gt;You probably need to take a step-by-step approach to make this work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Step 1: Connectivity to the database.&lt;/P&gt;
&lt;P&gt;You wrote that you've loaded data into a database table. Did you use SAS for this? If yes then make sure that you're using the exact same libname/libref now.&lt;/P&gt;
&lt;P&gt;If not: Try and see if there is already a SAS library defined for you (i.e. for SAS EG/Studio under the Server). If there is one activate the library (assign) and drill into it. Or: Is there someone else using SAS to connect to this database? If yes then get this already working libname statement from this person.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Step 2: List table metadata&lt;/P&gt;
&lt;P&gt;IF you've got a library defined then issue below statement (let's assume the libref is called mylib). Does this work? And in the report created do you see the table name you're after?&lt;/P&gt;
&lt;PRE&gt;proc contents data=mylib._all_ short;
run;&lt;/PRE&gt;
&lt;P&gt;Let's discuss step 3 once above is working. It should be simple and if you just need data read into SAS will likely not require a stored procedure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 30 Mar 2020 23:50:49 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2020-03-30T23:50:49Z</dc:date>
    <item>
      <title>Retrieve Dataset from SQL Server</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Retrieve-Dataset-from-SQL-Server/m-p/636015#M21342</link>
      <description>&lt;P&gt;Hii,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a created an ADSL dataset with multiple studies and I loaded this dataset in to a database to build a data repository.&lt;/P&gt;&lt;P&gt;Now,&amp;nbsp; I need to retrieve this ADSL dataset from Database to my study folder where&amp;nbsp;studyid = 6300.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From Data Management team I got below command and said&amp;nbsp;to execute the following procedure in SAS proc sql:&lt;/P&gt;&lt;P&gt;EXEC bst.usp_ADS_SHOW_DATASET &amp;nbsp;'6300', 'ADSL'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I didn't understand how to use mentioned command to retrieve the dataset. Can anyone suggest me a solution for this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;FYI:&lt;/P&gt;&lt;P&gt;I have tried below code but it didn't worked to me.&lt;/P&gt;&lt;P&gt;libname p2_ads oledb init_string = "Provider = SQLOLEDB.1;&lt;BR /&gt;BULKLOAD = YES;&lt;BR /&gt;Integrated Security = SSPI;&lt;BR /&gt;Persist Security Info = True;&lt;BR /&gt;Initial Catalog = VCDM_ANALYxxTIC;&lt;BR /&gt;Data Source = ITSUSRAxxxxx,1000"&lt;BR /&gt;Schema = BST;&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table adsl33 as&lt;BR /&gt;select *&lt;BR /&gt;from EXEC p2_ads.usp_ADS_SHOW_DATASET, "6300", "ADDX"&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LOG:&lt;/P&gt;&lt;P&gt;150 proc sql;&lt;BR /&gt;151 create table adsl33 as&lt;BR /&gt;152 select *&lt;BR /&gt;153 from EXEC p2_ads.usp_ADS_SHOW_DATASET, "6300", "ADDX"&lt;BR /&gt;-&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;ERROR 22-322: Syntax error, expecting one of the following: ;, ',', ANSIMISS, CROSS, EXCEPT,&lt;BR /&gt;FULL, GROUP, HAVING, INNER, INTERSECT, JOIN, LEFT, NATURAL, NOMISS, ORDER, OUTER,&lt;BR /&gt;RIGHT, UNION, WHERE.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;154 ;&lt;BR /&gt;155 quit&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank You for your time,&lt;/P&gt;&lt;P&gt;Santhosh.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Mar 2020 21:10:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Retrieve-Dataset-from-SQL-Server/m-p/636015#M21342</guid>
      <dc:creator>Kumar6</dc:creator>
      <dc:date>2020-03-30T21:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Dataset from SQL Server</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Retrieve-Dataset-from-SQL-Server/m-p/636023#M21344</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/319560"&gt;@Kumar6&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need an SQL Pass through&amp;nbsp; query to execute a SQL server Stored Process.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Syntax looks like this :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
	Connect to odbc (datasrc=&amp;lt;data source name&amp;gt; user = &amp;lt;user name&amp;gt; password = &amp;lt;pwd&amp;gt;);
		Execute(p2_ads.usp_ADS_SHOW_DATASET, "6300", "ADDX") by odbc;
	Disconnect from odbc;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Mar 2020 21:42:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Retrieve-Dataset-from-SQL-Server/m-p/636023#M21344</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2020-03-30T21:42:58Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Dataset from SQL Server</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Retrieve-Dataset-from-SQL-Server/m-p/636029#M21348</link>
      <description>Hi r_behata,&lt;BR /&gt;&lt;BR /&gt;What I have to provide for user and password.&lt;BR /&gt;for datasrc I have given ITSUSRAWSP02788,1433.&lt;BR /&gt;&lt;BR /&gt;I tried to run below code and I got a pop-up box of Data Link Properties, requested to enter server name, info to log onto the server and select database on server.&lt;BR /&gt;&lt;BR /&gt;libname p2_ads oledb init_string = "Provider = SQLOLEDB.1;&lt;BR /&gt;BULKLOAD = YES;&lt;BR /&gt;Integrated Security = SSPI;&lt;BR /&gt;Persist Security Info = True;&lt;BR /&gt;Initial Catalog = VCDM_ANALYTIC;&lt;BR /&gt;Data Source = ITSUSRAWSP02788,1433"&lt;BR /&gt;Schema = BST;&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;PROC SQL;&lt;BR /&gt;Connect to oledb (datasrc=ITSUSRAWSP02788,1433 user = skumar password =);&lt;BR /&gt;Execute(p2_ads.usp_ADS_SHOW_DATASET, "6300", "ADSL") by oledb;&lt;BR /&gt;Disconnect from oledb;&lt;BR /&gt;QUIT;&lt;BR /&gt;&lt;BR /&gt;Also in p2_ads library I don't see a dataset with usp_ads_show_dataset.&lt;BR /&gt;Once again I want to provide the command I got from DM team is&lt;BR /&gt;EXEC bst.usp_ADS_SHOW_DATASET '6300', 'ADSL'&lt;BR /&gt;&lt;BR /&gt;In my program I'm using P2_ADS instead of BST. Is that okay ?</description>
      <pubDate>Mon, 30 Mar 2020 22:19:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Retrieve-Dataset-from-SQL-Server/m-p/636029#M21348</guid>
      <dc:creator>Kumar6</dc:creator>
      <dc:date>2020-03-30T22:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Dataset from SQL Server</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Retrieve-Dataset-from-SQL-Server/m-p/636035#M21350</link>
      <description>&lt;P&gt;You probably need to take a step-by-step approach to make this work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Step 1: Connectivity to the database.&lt;/P&gt;
&lt;P&gt;You wrote that you've loaded data into a database table. Did you use SAS for this? If yes then make sure that you're using the exact same libname/libref now.&lt;/P&gt;
&lt;P&gt;If not: Try and see if there is already a SAS library defined for you (i.e. for SAS EG/Studio under the Server). If there is one activate the library (assign) and drill into it. Or: Is there someone else using SAS to connect to this database? If yes then get this already working libname statement from this person.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Step 2: List table metadata&lt;/P&gt;
&lt;P&gt;IF you've got a library defined then issue below statement (let's assume the libref is called mylib). Does this work? And in the report created do you see the table name you're after?&lt;/P&gt;
&lt;PRE&gt;proc contents data=mylib._all_ short;
run;&lt;/PRE&gt;
&lt;P&gt;Let's discuss step 3 once above is working. It should be simple and if you just need data read into SAS will likely not require a stored procedure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Mar 2020 23:50:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Retrieve-Dataset-from-SQL-Server/m-p/636035#M21350</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-03-30T23:50:49Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Dataset from SQL Server</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Retrieve-Dataset-from-SQL-Server/m-p/636060#M21360</link>
      <description>&lt;P&gt;To execute an SQL Server stored procedure you will probably need to do something similar to this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
Connect to oledb (datasrc=ITSUSRAWSP02788,1433 user = skumar password =);
Execute(EXEC bst.usp_ADS_SHOW_DATASET '6300', 'ADSL';) by oledb;
Disconnect from oledb;
QUIT;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please note you have to include the EXEC inside the brackets to tell SQL Server to run a stored procedure. Also note you can't add a SELECT statement in front of the SAS EXECUTE to read data. That has to be done in a separate SQL statement.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Mar 2020 03:15:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Retrieve-Dataset-from-SQL-Server/m-p/636060#M21360</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-03-31T03:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Dataset from SQL Server</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Retrieve-Dataset-from-SQL-Server/m-p/636276#M21371</link>
      <description>Hi saskiwi,&lt;BR /&gt;&lt;BR /&gt;As per your comments I tried below code by adding select statement in a separate SQL statement. The log says that library reference bst is not assigned.&lt;BR /&gt;Also I tried to run the program without lib reference(bst) then log says usp_ads_show_dataset is not exists.&lt;BR /&gt;&lt;BR /&gt;When I run the program without keeping separate SQL statement(which are line no: 13-15) program went through without errors but where can I see the retrieved data without giving create table statement ?&lt;BR /&gt;&lt;BR /&gt;libname tst "C:\Users\SDosapat\Desktop\e_tst";&lt;BR /&gt;&lt;BR /&gt;1.PROC SQL;&lt;BR /&gt;2.Connect to oledb (init_string = "Provider = SQLOLEDB.1;&lt;BR /&gt;3. BULKLOAD = YES;&lt;BR /&gt;4. Integrated Security = SSPI;&lt;BR /&gt;5. Persist Security Info = True;&lt;BR /&gt;6. Initial Catalog = VCDM_ANALYTIC;&lt;BR /&gt;7. Data Source = ITSUSRAWSP02788,1433"&lt;BR /&gt;8. Schema = BST );&lt;BR /&gt;9.&lt;BR /&gt;10.&lt;BR /&gt;11.Execute(EXEC bst.usp_ADS_SHOW_DATASET '6300', 'ADSL';) by oledb;&lt;BR /&gt;12.&lt;BR /&gt;13.Create table tst.adsl3 as&lt;BR /&gt;14.select *&lt;BR /&gt;15.from bst.usp_ADS_SHOW_DATASET;&lt;BR /&gt;16.&lt;BR /&gt;17.Disconnect from oledb;&lt;BR /&gt;18.quit;&lt;BR /&gt;&lt;BR /&gt;Thanks for your time.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Santhosh.&lt;BR /&gt;</description>
      <pubDate>Tue, 31 Mar 2020 16:11:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Retrieve-Dataset-from-SQL-Server/m-p/636276#M21371</guid>
      <dc:creator>Kumar6</dc:creator>
      <dc:date>2020-03-31T16:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Dataset from SQL Server</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Retrieve-Dataset-from-SQL-Server/m-p/636347#M21372</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/319560"&gt;@Kumar6&lt;/a&gt;&amp;nbsp; You need to use SQL passthru for your SELECT statement:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Create table tst.adsl3 as
select *
from connection to oledb
(select * from
bst.usp_ADS_SHOW_DATASET
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Mar 2020 19:52:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Retrieve-Dataset-from-SQL-Server/m-p/636347#M21372</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-03-31T19:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Dataset from SQL Server</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Retrieve-Dataset-from-SQL-Server/m-p/636576#M21383</link>
      <description />
      <pubDate>Wed, 01 Apr 2020 14:44:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Retrieve-Dataset-from-SQL-Server/m-p/636576#M21383</guid>
      <dc:creator>Kumar6</dc:creator>
      <dc:date>2020-04-01T14:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve Dataset from SQL Server</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Retrieve-Dataset-from-SQL-Server/m-p/636656#M21389</link>
      <description>Hi Saskiwi,&lt;BR /&gt;The below code worked for me to extract ADSL from DB for study 6300.&lt;BR /&gt;Is there any way to extract multiple studies in single time like in("xxxx" "xxxx" "xxxx" ).&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;Connect to oledb (init_string = "Provider = SQLOLEDB.1;&lt;BR /&gt;BULKLOAD = YES;&lt;BR /&gt;Integrated Security = SSPI;&lt;BR /&gt;Persist Security Info = True;&lt;BR /&gt;Initial Catalog = VCDM_ANALYTIC;&lt;BR /&gt;Data Source = ITSUSRAWSP02788,1433"&lt;BR /&gt;Schema = BST );&lt;BR /&gt;&lt;BR /&gt;Create table extract.adsl_6300 as&lt;BR /&gt;select *&lt;BR /&gt;from connection to oledb&lt;BR /&gt;( EXEC bst.usp_ADS_SHOW_DATASET "6300", "ADSL"&lt;BR /&gt;);&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;Thank you,&lt;BR /&gt;Kumar.</description>
      <pubDate>Wed, 01 Apr 2020 19:41:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Retrieve-Dataset-from-SQL-Server/m-p/636656#M21389</guid>
      <dc:creator>Kumar6</dc:creator>
      <dc:date>2020-04-01T19:41:14Z</dc:date>
    </item>
  </channel>
</rss>

