A c# sqlclr function containing DateTime.TryParse isn't returning the correct date on a new windows server. The date and regional settings were in US format on this server instead of GB and the sql server is using a managed service account.
I installed the English (United Kingdom) language pack and deleted the old one. Updated the regional settings for the UK date format and used the Administrative tab in the control panel regional settings to copy the settings to the welcome screen, system accounts and new users.
UK date parsing still does not work. Calling the function manually in powershell under my user account returns the correct value.
I tried changing the registry settings under the MSA account to match my current user based on this list but still no success. https://blogs.technet.microsoft.com/askperf/2012/08/16/how-to-change-regional-settings-for-all-users-on-a-computer/
SQL Server 2017 (RTM-CU6) on Windows Server 2016 build 14393
To update the regional settings of the managed service account (without recreating it) perform the following.
Run powershell using psexec from sysinternals. Leave the password blank and press enter. cmd would also work but powershell lets you easily test the function.
& 'psexec.exe' -u domain\msa$ -i powershell
Add the dll and check the function result.
Add-Type -Path "path\clr.dll"
[TypeConverter]::ftn_ConvertToDate("20/10/2017 00:00");
Incorrect result returned. Run intl.cpl in powershell. This will open the regional settings as the msa user. Set the format to English (United Kingdom) or another format as needed. This will change the settings for the MSA that the powershell session is run for.
Test again to see the correct result.
[TypeConverter]::ftn_ConvertToDate("20/10/2017 00:00");
Restart the SQL Service and the clr function will use the new date format.
Related
sql connection can be done if we have correct user name, password & DB name. I want to create a user if pre defined user is not available. is there a way to do it perhaps during the installation process (installing the .exe) ? Maybe using a powsershell script
we can use thhis batch script https://gist.github.com/djangofan/3792028 with some changes.
I'm running through the SQL Server 2014 install wizard, stopping before I get to the final step and then trying to use the Configuration.inf file to do "silentInstalls" on multiple servers. But, in the wizard I set the services (Ex: SQL Agent, ...) to a domain user, which requires a password. That password information is not included in the Configuration.inf file, so the unattended install obviously fails.
Questions:
I have to use a domain user if I am going to be using replication and other resources that require the SQL Server to communicate with each other, right?
How do I include the password for the domain service user in the Config.inf file?
Thanks,
Chris
I don't know what else you're using, but you don't need to use a domain user for replication. You can use a SQL account if you'd like (the documentation says so).
For the password issue, take a look at the list of parameters you can pass setup.exe (here). You can mix and match parameters and a config.ini. As such, you can set it up such that all you specify via command line switches is the various passwords you'll need (assuming that the service account is the same between all of your installs).
Has anyone out there been able to accomplish this task? InstallShield prompts the user to connect to their local / networked sql server database and collects all that information (server name, catalog, username, password, etc.).
I need to plug this information into a connection string for entity framework, not replacing attribute values, but actually doing a text replace within the attribute value. I.E. replace "MyServer" with the server name they connect to.
In working with InstallShield I do not see a way to take those connection settings and "plug them in" to the EF connection string. Anyone had success with this?
The answer for this is to use the InstallShield feature "Text File Changes" found under the "System Configuration" section. This feature allows you to take the user-defined connection properties for sql server and replace text in the config file.
For example, my base config file contains the text "Server=MyServerName;" in the connection string. InstallShield finds this text and replaces it with "Server=[IS_SQLSERVER_SERVER];" which comes from the prompt where the user connects to their sql server instance.
For some reason the "XML File Changes" does not allow for text replacement and that's where I was getting off track.
I need to install an ODBC database on a few computers and was hopeing to do it all via a batch file. I can get it to install the database connection string like so.
ODBCCONF.exe CONFIGSYSDSN "SQL Server" "DSN=DSNNAME | Description=Descriptionname| SERVER=ServerName | Trusted_Connection=Yes | Database=dbname"
pause
#CLS
#Exit
But i need to add that it should log in with with an Login ID and password NOT with the network login ID.
Anyone know how i can fix this?
also its on 64 bit windows 7
Thanks
http://social.msdn.microsoft.com/Forums/en-US/sqldataaccess/thread/53f689c1-53c8-45c6-b9ce-c44bce46cd9d/ says "Persistence of login credentials in a DSN is not supported (it's insecure). Using trusted connection would be the best way to achieve connecting without specifying credentials since the logged on user credentials is used for authenticating to the server."
If you change to Trusted_Connection=No it will add the DSN, but you'll then need to run the ODBC Data Source Admin and add the user and pwd to the new DSN by hand.
btw, according to http://msdn.microsoft.com/en-us/library/windows/desktop/ee388579%28v=vs.85%29.aspx "ODBCCONF.exe will be removed in a future version of Windows Data Access Components. Avoid using this feature, and plan to modify applications that currently use this feature."
Is there a way to automatically print a SQL Server Reporting services (2005) report?
EDIT:
We needed to print a SSRS report at a network printer programmatically. Specifically, we wanted to fire this off from a stored procedure. We are currently using likeabanshee's method, and it is working. However, we would like something more managed, without the dependency on Adobe Acrobat and xp_cmdshell. We are looking into this method suggested by Paul G.
You should be able to make that happen programmatically using the built-in web service to render the report. Some sample code for SSRS 2000 is here, but it should be pretty close to what you'd need for 2005 as well I think:
If you use the Microsoft Business Intelligence Editor to create your SSRS, you can write code to fire off a print job.
This question was posted by a co-worker for me. My comments and resolution follow:
Background:
I essentially wanted to fire off SSRS reports to networked printers at our corporation through their UNCs. I have a real-time quality monitoring app (for an industrial manufacturing facility) running from SQL Server. As severe defects are detected I wanted to send a report to QA printers for them to analyze the defects. It also supplements our pager/email alerting system to stop problems as they are occuring.
Solution:
I wrote a SQL stored procedure to monitor the quality failures. As they are detected, the stored procedure calls a .Net console app using xp_cmdshell, passing the product ID, UNC path, report name, Adobe Reader file path (on the SQL Server) and a few other parameters. Note the console app resides on the same server as the SQL Server. The console app accepts the paramters and passes them to SSRS with an output format of PDF. The PDF is created and saved locally, then the console apps runs a command line using Adobe Reader's hidden run mode (/t). The file path and UNC path are passed as parameters, and voila - automatic printing of SSRS files.
An optional parameter tells the console app whether to delete the locally saved PDF.