SQL Server Mangement Studio - Generated database script not working - sql-server

I am having trobule trying to copy a database using sql server management studio.
The script which was generated using the wizard throws the following error when I try to run it to create the new database;
Reference to database and/or server name in
'databasename'.dbo.sp_fulltext_database' is not supported in this
version of SQL server
This is despite generating the script using the correct version number and a couple of other ones to test.
I am following the steps in the following post
http://johanbenjaminsson.com/how-to-make-a-copy-of-an-umbraco-database/
Steps are not the exact same as the post is from a while back but the process is the same.
The line that seems to have the error is the following
EXEC [<databasename>].[dbo].[sp_fulltext_database| #action = 'enable'
Struggling with this so any advice would be great.

Related

Generate Scripts for entire database - why SQL Server try to create views first

I am using SQL Server 2019 developer version - 15.0.2000.5.
I used Generate Scripts for entire database - just checked all and generated scripts. But upon running file I noticed errors at beginning and everything worked except for views. It seems that SQL Server added creating scripts for views at the beginning of file. Is there a way I could re-arrange this or is this a bug? What I did to fix was just re-run only view scripts - but it just seems like Microsoft should know better.
SQL Server 2016 express does same thing also?

Azure SQL Managed Instance T-SQL query debugging

When trying to debug a T-SQL query within Azure SQL Managed Instance database from Visual Studio, I get an error:
Failed to start debugger and exception was generated: Data is null. This method or property cannot be called on null values
Followed by this:
Unable to start program MSSQL Operation not supported Unknown error 0x80004005
Debugging a T-SQL query from within Visual Studio 2019 current version 16.11.11 yields the following errors:
Failed to start debugger and exception was generated: Data is null. This method or property cannot be called on null values
Unable to start program MSSQL Operation not supported Unknown error 0x80004005
Azure SQL Managed Instances cannot be debugged using the debug method of SSMS or via Visual studio. Answer by the MS support team : " As discussed Azure SQL Managed Instance does not support debugging as SQL Server engine DDL’s which is required by the debugger are not accessible in PaaS environment."
On all Azure SQL PaaS database options (DTU model, vCore model, Serverless, Managed Instance, Hyperscale) and Synapse you will have that constraint. Even tools like SQL Server Management Tools (SSMS) that once had a Debugger integrated it no longer has it, and honestly it was never useful when I had to use it.
Azure Data Studio has a Profiler Extension that help a little bit to determine the sequence of instructions that were executed to produce a result set but won't help you to watch the values of variables.
If all this is painful for you maybe your organization should consider choose a SQL Server VM (IaaS) instead of PaaS.
You can also export Azure SQL Databases to a local developer environment and do debugging locally.
Finally, if you need to debug on Production use PRINT or SELECT statements of T-SQL to watch the values of variables or display intermediate result sets. You can also save intermediate results or outputs into a temporary table or log table.

SQL backup file made with MSSMS is not working... on MSSMS (Microsoft SQL Server Management Studio)

I Generated an SQL File to backup a database using MSSMS:
Right click on database
Generate scripts
Marked "Schema and data" on "Types of data to script"
As a result I got a complete SQL that effectively seems to contain all the needed information to rebuild my db from scratch, data included.
To test it, I tried to run it locally, and found myself stuck because MSSMS is throwing errors on the SQL Script that it itself made.... I does not make any sense :(
Am I missing sth?:
This is the first lines of the sql file just as MSSMS made it:
Any ideas?
EDIT 1
This is the error I get after removing all "ALTER DATABASE" (I assumed those were the configuration specifications that were causing trouble)
It now says the tables are already created though they are not present in the database (it did create the database tough, It's a progress!)
The script you are trying to execute contains elements that are not valid because the edition of SQL you are running locally is not the same as the edition of SQL used to generate the script.
In your case, the script was generated from azure SQL, but you are running it on sql server express edition (localdb)
Remove the azure SQL specific elements and it will work.
The default scripting option in SSMS object explorer is the same database engine type and edition as the source database. It seems the source database is Azure SQL Database based on the CREATE DATABASE syntax so the script will not run against a stand-alone instance like your LocalDB instance.
You can either modify the script or generate a new script appropriate for your target instance. To generate a script for SQL Express LocalDB, click on the Advanced button on the Set Scripting Options page of the Generate Scripts wizard. Select these options:
Script for the database engine edition: Microsoft SQL Server Express Edition
Script for the database engine type: Stand-alone instance

Connect SQL Server Visual Studio to SpiceWorks SQLite Database Failure

Windows Server 2012
SQL Server 2014
Visual Studio 2013 Professional
SpiceWorks 7.5.00101 / SQLite 3.7.15.2
I am trying to connect SQL Server / Visual Studio to the SpiceWorks SQLite database so I can make a report showing the currently open tickets and who is assigned to them. This report is for the front desk receptionist so she can refer ticket creators that call in to the right person in IT. We don't want her to be able to see potentially sensitive data within the tickets.
I cannot get the connection to work!
I have tried both the 32 and 64 bit sqlite odbc drivers from here: http://www.ch-werner.de/sqliteodbc/
I use the C:\Windows\SysWOW64\odbcad32.exe to create the 32bit ODBC DSN using the SQLite3 Driver
I use the C:\Windows\System32\odbcad32.exe to create the 64bit ODBC DSN using the SQLite3 Driver
When I attempt to use the 32bit DSN to create either a Linked Server OR when used in a SQL Report (SSRS) as a DataSource I get this error:
The specified DSN contains an architecture mismatch between the Driver and Application
Which is supposed to mean that I used the wrong odbcad32 to create it - but I didn't (I've recreated this damn thing several times)
When I attempt to use the 64bit DSN I get this error:
IM006[Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed
All I can find is a HotFix for this reported error
https://support.microsoft.com/en-us/help/822841/fix-setting-of-connection-attribute-fails-when-you-use-connection-pool
however when I tried to instal the hotfixes they error saying they cannot determine the version of Data tools.
I have tried this on a Windows Server 2008 where the SpiceWorks software/database is installed, and from our Windows 2012 w/SQL Server 2014 using the fully qualified path "\ \spwrks\c$\Program Files (x86)\Spiceworks\db\spiceworks_prod.db" and get the same results.
I have tried pointing to the production database and to a copy of the database.
I have tried to uninstall all of the SQLite drivers and start from scratch. When the 32bit one fails, I uninstall, reboot, and install the 64bit one and it fails.
A very weird part to this is if I create a Server Explorer > Data Connection inside of Visual Studio 2013 pointing to the 32bit DSN , I can see all of the tables, create and execute a query against it without any problems.
Once I publish (deploy) the SSRS report and try it from the browser I get the " The specified DSN contains an architecture mismatch between the Driver and Application" error inside the browser.
This is driving me nuts. Help!
I have tried following the instructions on these links:
https://community.spiceworks.com/how_to/128624-export-spiceworks-sqlite-data-to-ms-sql
https://community.spiceworks.com/how_to/2271-create-ms-sql-linked-server-to-the-spiceworks-sqlite-server
https://community.spiceworks.com/how_to/28362-view-the-spiceworks-database-and-create-sql-reports
https://community.spiceworks.com/topic/132253-how-do-i-generate-a-spiceworks-report-using-sql-server-2008-reporting-services
Just an update
I have made a SSIS Import job that first copies the existing SQLite database, so I don't mess with the production, then imports the two tables I need (tickets and users) into the 2014 SQL Server. Then, I want to run a report off of those tables.
It seemed to work when I ran the job inside of Visual Studio, but once I tried to schedule the job with SQL Agent it failed to connect to the ODBC. Which made me think of a permission problem since running it inside the SSIS works. I went back to the SpiceWorks folder and database and set permissions to Full Control for Everyone just to see, but it still doesn't want to connect.
As, I have been trying to get it to work; just an hour ago, my production and copied SpiceWorks database became corrupted - not sure if copying it made it happen or what. The whole thing is very... "finicky". I wasn't writing anything to it, just trying to connect and do 2 simple SELECT statements.
Luckily, I had backup copies of the SpiceWorks database and was able to restore it. 
I've never had so much trouble just trying to get data from a database!
After assistance from Robert with Microsoft, the solution was to disable the Run64BitRuntime option under the Property Page for the SSIS Project (right-click on the Project, select Properties, then under Configuration Properties > Debugging, set Run64BitRuntime to False) , because the SQLite is 32bit.
More information can be found here:
http://help.pragmaticworks.com/dtsxchange/scr/FAQ%20-%20How%20to%20run%20SSIS%20Packages%20using%2032bit%20drivers%20on%2064bit%20machine.htm

Issues Creating SQL Server triggers using SQuirreL SQL Client

Recently I have been working with a SQL Server database and I was trying to create some triggers for some tables using SQuirreL SQL Client and for some reason I was unable to get rid of the following pesky error message:
"Error: 'CREATE TRIGGER' must be the first statement in a query batch.
SQLState: S0001
ErrorCode: 111"
The query I was attempting to execute was the following (I started out with a really simple trigger to make sure the syntax was correct):
CREATE TRIGGER meeting_overlap on adhoc_meeting
FOR INSERT
AS
DECLARE
#myvar INT
When I attempted to execute my exact same query in Microsoft SQL Server Management Studio Express it executed fine. My question is: has anyone else run into similar problems using SQuirreL SQL Client and if so, what did you do to get rid of this error?
EDIT:
I am using SQuirrel SQL v2.6.8 with the Microsoft SQL Server JDBC Driver 2.0 and I am connecting to SQL Server 2005.
I was having the same problem. After some Googling, I found this article:
http://vsingleton.blogspot.com/2009/04/error-create-view-must-be-first.html
In short, wrap exec('') around your create trigger statement. In addition, any single quotes (') you have in the trigger statement need to be changed double single quotes ('').
Usually you get that error when attempting to run multiple statements in the same batch that are not allowed to be anything but the first statement in a batch. You may need a GO in between them. GO is not a SQL command but really a directive to the client tool to separate batches of commands.
I couldn't replicate this on SQuirrel SQL v2.6.8 using v1.2.2 of the jTDS jbdc driver against SQL 2005 SP3 (developer edition).

Resources