I am trying command like
USE [aaa]
GO
SELECT [Id]
,REPLACE([BlaBlaField], 'xyz','')
FROM [dbo].[aaa]
GO
through SQL Management Studio on SQL EXPRESS and SQL Azure Web Edition DB. In SQL Express it works, but on Azure it does not. I searched on the web at 'Azure SQL Database General Guidelines and Limitations' page and on this page but the command was not listed as not supported. Is it supported or not?
UPDATE
The problem appears only when I use cyrillic symbols. For example :
USE [aaa]
GO
SELECT [Id]
,REPLACE([BlaBlaField], '2004','-')
FROM [dbo].[aaa]
GO
works but :
USE [aaa]
GO
SELECT [Id]
,REPLACE([BlaBlaField], '2004г','')
FROM [dbo].[aaa]
GO
UPDATE - PROBLEM SOLVED
The problem was solved by not using REPLACE but a combination of LEFT, RIGHT, SUBSTRING and CHARINDEX avoiding the use or cyrillic characters.
does not.
The replace function itself works in Azure SQL Database.
What does not work in SQL Database is USE [aaa]. You have to connect to the correct database first and then issues the statement in.
Related
I'm writing a SQL script that needs to be able to run on multiple SQL engines, namely SQL Server and Azure SQL. An IF statement checks the database version to execute the correct code. But the code won't compile if used on the wrong engine.
This works fine in Azure SQL, but SQL Server rejects it.
IF (##VERSION LIKE 'Microsoft SQL Azure %')
BEGIN
ADD SENSITIVITY CLASSIFICATION TO [dbo].[User].[UserName] WITH (LABEL = 'Confidential', INFORMATION_TYPE = 'Credentials')
...
END
GO
What are my options for ensuring this is accepted by both engines?
Dynamic SQL could be used to circumvent syntax check:
IF (##VERSION LIKE 'Microsoft SQL Azure %')
BEGIN
EXEC('ADD SENSITIVITY CLASSIFICATION TO [dbo].[User].[UserName] WITH (LABEL = ''Confidential'', INFORMATION_TYPE = ''Credentials'')');
...
END
GO
Please note that all ' have to be quoted i.e.''. Add support for here-strings i T-SQL
ADD SENSITIVITY CLASSIFICATION will be supported starting from SQL Server 2019.
I just upgraded my SSMS to 2008 R2. I'm missing the option to select the top 1000 rows from a table, like this:
Mine looks like this:
I know how to change the number of rows that are displayed, but the options aren't there at all. I saw that someone submitted a bug for this a few years ago, but there was no workaround, and I'm not sure what to do. Any ideas?
EDIT - Azure Problem?
I just used SSMS to open my local SQL Server, and I get the option to select the top 100 rows. But in my other SSMS instance, the one that is connected to my Azure DB, I don't see it. Is it possibly an Azure limitation?
Based on this answer, I believe it is a limitation of SQL Azure. I have not been able to find any additional information that would allow you to work around the issue.
As of 06/04/2015 MS has published a hotfix to solve this issue.
http://support.microsoft.com/en-us/kb/3011055
"An update is available that enables "Select Top 1000 Rows" option for tables and views of SQL Azure database"
You do not have this option in SSMS while working with SQL Azure, you have to exexute the query yourself ... select top 10000 from tablename
There are few other options as well in SSMS which are not displayed in case of SQL Azure.
This is an excpected behaviour for SQL Azure.
It is now available on SqlServer Mgt Studio 2014.
Check that you have correct values in the SQL Server Object Explorer Settings:
I've been using #DBCommand on MySQL db's. Great success. Now I have to switch to SQL Server.
I manage to update the SQL Server database just fine (via Domino).
The problem occur when I try to generate a report for the web user (Domino).
The query works like a charm in SQL Server Management Studio. Running the web page yields:
Data Access Application Layer>Could not execute #db function
The original query worked just fine against MYSQL.
I am in need of some resources/documentation/web page describing hints and tips in order to make it work. Any ideas?
Example query that fails (when using Domino):
SELECT COUNT( bruk_NR ) as [antall], [brukere_Navn], [bruk_NR]
FROM [stat].[dbo].[bruk]
INNER JOIN
[stat].[dbo].[brukere]
ON bruk.bruk_NR = brukere.brukere_NR AND bruk.bruk_NR = brukere.brukere_NR
GROUP BY bruk.bruk_NR, brukere.brukere_Navn, brukere.brukere_brukerID
ORDER BY [brukere_brukerID] ASC
Thanks in advance
Hal.
I'm using SSEUtil to automatically create a functional test database from the schema derived from my development database (SQL Server 2008 R2) as part of my build process. This allows me to keep the two databases in-sync (schema-wise) without running SQL repository tests against my development database.
I recently added a full text index to a table for the first time for this project in my development schema and now when I attempt to apply the schema to a newly created unit test database I get the following error when it executes the SQL to create the full text catalog:
CREATE FULLTEXT CATALOG [FullTextCatalog] AUTHORIZATION [dbo]
GO
Cannot use full-text search in user instance.
[SqlException Number 9982, Class 16, State 100, Line 1]
I've searched high and low. The only help I found was on another site where someone suggested "attaching to the parent database." I have no idea what that means. And I have no idea what this error means. What is a "user instance"?
Can anyone suggest a way around this? Is there a better way to keep two database schemas in-sync for continuous integration?
Either
User must have CREATE FULLTEXT CATALOG permission on the database, or be a member of the db_owner, or db_ddladmin fixed database roles.
or
you won’t be able to use full text catalogues if the SQL instance does not have it installed. Make sure the SQL server instance has the full text service running.
Here are two ways of testing whether this feature installed or not. This feature is available for all editions of SQL Server 2005 and 2008 (including SQL Express)
Check the services applet (run -> type 'services.msc') for this entry :
SQL Server FullText Search Or SQL Server FullText Search (SQLEXPRESS) (in case of SQL Express). Start this service of not running
Run the query "select fulltextserviceproperty('isfulltextinstalled')" in the Query analyzer. if the result is '1' then it is installed else not.
In the case of unavailability of this feature, you need to install by downloading the "SQLEXPR_ADV.EXE" from http://www.microsoft.com/express/sql/download/default.aspx
Reference taken from here
This is not really an answer to the question, but I came upon a similar issue with visual studio package manager when updating an entity framework code-first database (command update-database).
The problem was that I selected the wrong start-up project, and therefore visual studio was not using my connection string at all. It was connecting to a localdb instance, hence the cryptic error message "cannot use full text search in user instance". Once I made it connect to the actual database, it worked as expected.
I also came across this user instance issue. I have to admit that I only have basic knowledge of SSMS. Apparently I'm logged as the public user. How can I be a member of db_owner? I try to generate and script everything without using the GUI.
For example, if I execute this
ALTER AUTHORIZATION ON DATABASE::[dbname] TO sa;
EXEC sp_changedbowner 'sa';
I still get the Cannot use full-text search in user instance error with
USE [dbname]
CREATE FULLTEXT CATALOG [ftc_dbname] AS DEFAULT
GO
I can't seem to figure out how to set the default database in Sql Server from code. This can be either .Net code or T-Sql (T-Sql would be nice since it would be easy to use in any language). I searched Google and could only find how to do it in Sql Server Management Studio.
ALTER LOGIN should be used for SQL Server 2005 or later:
http://technet.microsoft.com/en-us/library/ms189828.aspx
ALTER LOGIN <login_name> WITH DEFAULT_DATABASE = <default_database>
sp_defaultdb eventually will be removed from SQL Server:
http://technet.microsoft.com/en-us/library/ms181738.aspx
from: http://doc.ddart.net/mssql/sql70/sp_da-di_6.htm
sp_defaultdb [#loginame =] 'login' , [#defdb =] 'database'
Thanks Stephen.
As a note, if you are using Windows Authentication, the #loginname is YourDomain\YourLogin (probably obvious to everybody else, but took me a couple tries.
sp_defaultdb #loginame='YourDomain\YourLogin', #defdb='YourDatabase'
If you're trying to change which database you are using after you are logged in, you can use the USE command. E.g. USE Northwind.
https://www.tutorialspoint.com/sql/sql-select-database.htm