<?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: What is the current user for an ODBC Trusted Connection to SQL Server? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-current-user-for-an-ODBC-Trusted-Connection-to-SQL/m-p/290919#M60256</link>
    <description>&lt;P&gt;There is the th BL_KEEPNULLS options that seems to be tailored for this problem.&amp;nbsp;Unfortunately it seems only to be supported for OLEDB connections.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For ODBC you&amp;nbsp;could try setting the &lt;SPAN class="xis-keyword"&gt;IGNORE_READ_ONLY_COLUMNS to YES, if I recall right I think we solved this problem by doing that.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Aug 2016 08:55:54 GMT</pubDate>
    <dc:creator>LinusH</dc:creator>
    <dc:date>2016-08-11T08:55:54Z</dc:date>
    <item>
      <title>What is the current user for an ODBC Trusted Connection to SQL Server?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-current-user-for-an-ODBC-Trusted-Connection-to-SQL/m-p/290914#M60253</link>
      <description>&lt;P&gt;My SQL Server table has a few default contraints:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[Name] [varchar](8) NOT NULL,
[Sex] [char](1) NOT NULL CONSTRAINT [DF_TARGET_SEX]  DEFAULT ('U'),
[Age] [int] NOT NULL CONSTRAINT [DF_TARGET_AGE]  DEFAULT ((-1)),
[Height] [numeric](7, 1) NOT NULL CONSTRAINT [DF_TARGET_HEIGHT]  DEFAULT ((-1)),
[Weight] [numeric](7, 1) NOT NULL CONSTRAINT [DF_TARGET_WEIGHT]  DEFAULT ((-1)),
[valid_from] [datetime2](0) NOT NULL CONSTRAINT [DF_TARGET_VALID_FROM]  DEFAULT (getdate()),
[valid_to] [datetime2](0) NOT NULL CONSTRAINT [DF_TARGET_VALID_TO]  DEFAULT ('9999-12-31 23:59:50'),
[current_record] [char](1) NULL CONSTRAINT [DF_TARGET_CURRENT_RECORD]  DEFAULT ('Y'),
[DimensionCheckSum] [int] NOT NULL CONSTRAINT [DF_TARGET_DimensionCheckSum]  DEFAULT ((-1)),
[LastUpdated] [datetime] NOT NULL CONSTRAINT [DF_TARGET_LastUpdated]  DEFAULT (getdate()),
[UpdatedBy] [varchar](50) NOT NULL CONSTRAINT [DF_TARGET_UpdatedBy]  DEFAULT (SUSER_SNAME()),&lt;/PRE&gt;&lt;P&gt;If I submit this in SSMS,&amp;nbsp;all the above fields are auto-populated, and get their default values:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;INSERT INTO tmp.target (Name) VALUES ('A') &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I have an ODBC connection to this table in SAS, and I execute the below code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data foo;
   if 0 then set tmp.target (keep=name);
   Name='B';
   output;
   stop;
run;

proc append base=tmp.target data=foo force nowarn;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the default values are auto-populated, except for UpdatedBy and Sex.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I use explicit pass-through it works as expected:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc sql;
   connect using tmp;
   execute(
INSERT INTO tmp.target (Name) VALUES ('C') 
   ) by tmp;
quit;&lt;/PRE&gt;&lt;P&gt;My ODBC libref is allocated as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro allocate_sqlsvr_database(libref=,database=,schema=dbo);
   %* set connection string ;
   %let connect = NOPROMPT="Driver={SQL Server Native Client 10.0};Server=XXXXX,#####;Database=&amp;amp;database;Trusted_Connection=yes;";
   %* set any libname options ;
   %let options = bulkload=yes schema=&amp;amp;schema reread_exposure=yes DBINDEX=YES UPDATE_LOCK_TYPE= NOLOCK;
   %* issue the libname statement ;
   libname &amp;amp;libref odbc &amp;amp;connect &amp;amp;options;
%mend;

%allocate_sqlsvr_database(libref=TMP, database=MyDatabase,schema=tmp)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas why these two default values aren't populated when using PROC APPEND? &amp;nbsp;Esp. UpdatedBy? &amp;nbsp;Could this be a bug?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SAS 9.3 on Windows...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2016 08:30:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-current-user-for-an-ODBC-Trusted-Connection-to-SQL/m-p/290914#M60253</guid>
      <dc:creator>ScottBass</dc:creator>
      <dc:date>2016-08-11T08:30:51Z</dc:date>
    </item>
    <item>
      <title>Re: What is the current user for an ODBC Trusted Connection to SQL Server?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-is-the-current-user-for-an-ODBC-Trusted-Connection-to-SQL/m-p/290919#M60256</link>
      <description>&lt;P&gt;There is the th BL_KEEPNULLS options that seems to be tailored for this problem.&amp;nbsp;Unfortunately it seems only to be supported for OLEDB connections.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For ODBC you&amp;nbsp;could try setting the &lt;SPAN class="xis-keyword"&gt;IGNORE_READ_ONLY_COLUMNS to YES, if I recall right I think we solved this problem by doing that.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Aug 2016 08:55:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-is-the-current-user-for-an-ODBC-Trusted-Connection-to-SQL/m-p/290919#M60256</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-08-11T08:55:54Z</dc:date>
    </item>
  </channel>
</rss>

