I'm creating an index in a SQL Server table with ONLINE = ON option:
CREATE INDEX IX_Name ON Users (Name) WITH ONLINE = ON
If this script is run on non-Enterprise SQL Server edition I get this error:
Online index operations can only be performed in Enterprise edition of SQL Server.
How to write a SQL script to use ONLINE = ON option on Enterprise editions and not to use it for non-supported editions?
Something like this should help
IF SERVERPROPERTY ('edition') like '%Enterprise%Edition%'
BEGIN
CREATE INDEX IX_Name ON Users (Name) WITH ONLINE = ON
END
Also I think the login you are using should have permission to View Server State
Related
It is really strange in SSMS, I have installed and confirmed twice that Full-Text search is installed, and it is up and running but while creating FullTextCatalog I get the same error again and again.
Version :
Microsoft SQL Server 2016 (SP1) (KB3182545) - 13.0.4001.0
CREATE FULLTEXT CATALOG FullTextCatalog
CREATE FULLTEXT CATALOG [FullTextCatalog] AUTHORIZATION [dbo]
ERROR:
Msg 9982, Level 16, State 100, Line 5
Cannot use full-text search in user instance.
Completion time: 2022-09-21T13:34:10.2052908+05:30
LocalDb is a user instance server meaning it starts on demand and does not run constantly. Because of this, it is not able to support a full text catalog.
If you need full text catalog, you need to install a persistent server of Sql Server Express. You can download it here: https://www.microsoft.com/en-us/sql-server/sql-server-downloads.
I have Azure SQL DB Server + one Azure SQL database on it. Within this DB I have functions which call some functions of master DB as a part of their logic.
Example:
CREATE FUNCTION [dbo].[EncryptByKey]
(
#EncryptionKeyId nvarchar(1024),
#ValueToEncrypt varchar(MAX)
)
RETURNS VARCHAR(MAX)
AS
BEGIN
RETURN master.dbo.fn_varbintohexstr(ENCRYPTBYKEY(Key_GUID(#EncryptionKeyId), #ValueToEncrypt))
END
Gives me an error:
Cannot find either column "master" or the user-defined function or
aggregate "master.dbo.fn_varbintohexstr", or the name is ambiguous.
If instead I try:
exec master.dbo.fn_varbintohexstr(123)
The error I get is:
Reference to database and/or server name in
'master.dbo.fn_varbintohexstr' is not supported in this version of SQL
Server.
Are there any solutions on how to use master DB functions from user's DBs on Azure SQL server?
You cannot use distributed database queries using three or four part names on SQL Azure.
For queries that span multiple databases in SQL Azure, you need to use elastic queries. For more information, please visit this article.
please help: I'm new to linked servers & in MS SQL I have successfully added one (from an MS Access file) as shown:
I'm having trouble querying this database here. What is the syntax? Thanks.
Okay, by simply using Management Studio in MS SQL I ran a SELECT query on the table through "Script Table as" (right-click) and with query results I was sure that this then is the format:
SELECT * FROM [RXPIPEDB]...[product]
Furthermore, I can run updates using this syntax:
UPDATE [RXPIPEDB]...[Product]
SET X = ..something..
Of-course for the UPDATE query, you must have set your LINKED SERVER properties > Server Options "RPC" & "RPC out" to TRUE.
Thank you all.
The query its OK. U have a problem in the configuration of linked server.
Check this: Run a Query from Linked Server (Oracle) in SQL Server2008 R2
I normally live in a MySQL world where I can use the
SHOW CREATE TABLE <tablename>
syntax to get the create script of a given table.
I'm working with a legacy SQL Server CE 3.5 database and need to get the create script for all of the tables so I can move them into another database which will be created by my application.
Is there any equivalent to the MySQL functionality that would allow me to do this?
YOu can use my free tool to to script object creation and data statements from a SQL Compact database - http://sqlcetoolbox.codeplex.com
I need to create sql database just like other sql database (without the data) via sql script
some one told me that Oracle has this ability by some code like
create database <your new DB name> as <the old DB name>
so is there a similar statement or workaround in SQL
I use MS-SQL Server 2008/2008R2
I don't want the 'generate scrip' solution as this provide a very long script, I just need the Oracle statement (mentioned above) but in SQL
to be more clear I need the tables structure only (no data) and need all other objects such as functions, views etc...
Please advice,
In SQL Server, you can right click on the database then select "Tasks" then "Generate Scripts" and you can build one script for all your object sans data.
If you are asking about SQL Server (at least in 2005 or newer, not sure about previous versions) if you right click on a Database in SQL Server Management Studio Go To Tasks and then Generate Scripts you have the option to Generate a script to create all the object ins the Database w/o Data.
Update:
You can also right click on a User Database and select Script Database as -> Create To just to get the TSQL to create the DB itself without any of the tables, stored procedure etc.