ssms

can't get EnumScript() to generate constraints

懵懂的女人 提交于 2019-12-11 11:22:34
问题 I'm trying to get programmatically what I can get manually from SSMS using Tasks > Generate Scripts The code below works fine, EXCEPT it doesn't generate any constraints. I don't get any ALTER TABLE [foo] ADD CONSTRAINT ... ON DELETE CASCADE etc etc. I've tried a lot of combinations of Dri options and on different databases as well. I'm stumped. Thanks for insight! Scripter scrp = new Scripter(srv) { Options = { ScriptDrops = false, WithDependencies = false, Indexes = true, Triggers = false,

How to convert a string into date format

*爱你&永不变心* 提交于 2019-12-11 11:05:41
问题 I have the following column, date_period2 in my query which displays date in yyyy-mm format but as a string. date_period2 201304 201305 201306 201307 How can i convert that to a DATE format so I can use it to get the working days of the specific month. So for example, 201304 would be converted to 04-2013 as a DATE instead of a string. This is my query which is calculating an expression based on the date_period2 field and it's not working because it's a string format: SELECT TOP 1000 [date

Login failed for user a\b

空扰寡人 提交于 2019-12-11 10:07:13
问题 I created a SQL connection as below: SqlConnection scSqlConnection = new SqlConnection("Server= " + ".\\" + strInstanceName + ";Initial Catalog=" + "master" + ";Integrated Security=True;"); and when I try to open this connection in my application there's no problem so I expect to be able to connect via SSMS in windowsAuthentication mode, but when I try to connect via SQL server management with Server name = .\strInstanceName in windowsAuthentication mode, I get the following error : login

“Requested conversion is not supported” using a linked server and ODBC

試著忘記壹切 提交于 2019-12-11 09:46:10
问题 Our web application stores UTF-8 encoded data in VARCHAR fields. Recently, we have provided our customers access to this data via ODBC using DataDirect's OpenAccess ODBC driver. This is achieved using DataDirect's OpenAccess SDK, writing a C# .Net class to interface with the service. We only allow customers to perform SELECT queries. We also limit results to 100K rows at this time. This solution really works great, except querying fields with some of this encoded data appeared as gibberish to

Automate Generate Scripts Wizard in SQL2008

旧城冷巷雨未停 提交于 2019-12-11 09:28:56
问题 Problem: how to automate a Generate Scripts in SQL2008 Management Studio: ie right click on database, Tasks, Generate Scripts All Tables All Stored Procs Create drop statements Don't use USE statement Generate data This is a 20sec process to do by hand.. needs automating :-) I don't really want to code it in C# in SQL Server Management Objects (SMO). Maybe I'll have to use AutoHotKey :-) 回答1: Use SMO - it's the right thing to do and you know it! 回答2: Have a look at DBSourceTools. http:/

How do you send in multiple commands to Sql PowerShell from the Windows Command Line?

一世执手 提交于 2019-12-11 09:06:08
问题 Not sure if this belongs on serverfault or not... I am following the instructions on this site for adding registered servers to sql studio management studio via powershell. It works great one at a time, but I need to do it for 60 servers. I have a batch set up with the code for each create that I need. I can't get the syntax right for calling sqlps by the command line and passing in the whole series of commands. My batch is set up like so: sqlps -NoExit -Command { cd 'SQLSERVER:

No default service level objective found of edition “GeneralPurpose”

孤者浪人 提交于 2019-12-11 08:47:01
问题 I am getting this error No default service level objective found of edition "GeneralPurpose" in SSMS when creating database in Azure SQL 回答1: Please download the latest SQL Server Management Studio version from here. Version 18.0 has many fixes related to Azure Managed Instances. It is a limitation of the free subscription you are using at this time. ""'Free Trial subscriptions can provision Basic, Standard S0 through S3 databases, up to 100 eDTU Basic or Standard elastic pools and DW100

SQL Server Management Studio does NOT let me create multiple foreign keys to multiple primary keys

半腔热情 提交于 2019-12-11 08:34:13
问题 I have a table ApplicationRegion in a one-to-many relationship to Translation . I want to set FK's from Translation.appname/isocode to ApplicationRegion.appname/isocode But that did not work as you can see from the screenshot. When the FK configure window opens 3 columns are shown on the left/right side appname isocode resourcekey Then I chose as parent table ApplicationRegion and removed the resource key column from the FK setting. And clicked OK but then I got the error you see on the

Is there a way to directly compress/zips the result from a SQL query?

安稳与你 提交于 2019-12-11 07:55:15
问题 Off late I have been dumping relatively large tables using SSMS. The usual way is to set Query->Results-To->File , 'Execute`, choose a file and let the SQL query run. After it finishes, I usually zip the file and then transfer it to my local machine. This has obvious problems of the host machine running out of space during overnight SQL queries. I was wondering if there is a way to compress the output from SSMS directly without having to wait until it dumps the results from the entire query.

In SSMS, display DateTimeOffset value in local timezone

纵饮孤独 提交于 2019-12-11 06:34:22
问题 Isn't there a way to configure Sql Server Management Studio to, in query results, display the value of a DateTimeOffset column in the client's local timezone, instead of UTC? Example: I'm in timezone +02:00. A value is stored as 2016-07-27 22:00:00.0000000 +00:00 . Currently, this value is displayed as such in query results. I want it to be displayed (formatted) as 2016-07-28 00:00:00.0000000 +02:00 when executing this query on SSMS on my machine. Currently I'm manually using something like