sql-server-2008-r2

How to enable “World Wide Services (HTTP)” in the firewall using command line?

丶灬走出姿态 提交于 2019-11-30 17:02:55
I'm trying to share my site in the local network. I want to use command line tool to perform this action. Manually: To enable http access through Windows Firewall on Windows 7. From the start menu begin typing "Allow a program through Windows Firewall". Scroll the bottom of the list and look for World Wide Web Services (HTTP) and enable it on your networks. It works fine. Command line doesn't work: >> netsh advfirewall firewall set rule name="World Wide Web Services (HTTP)" new enable=yes Error: No rules match the specified criteria. What is wrong in the command line? I had same problem when i

Selecting multiple rows by ID, is there a faster way than WHERE IN

时光怂恿深爱的人放手 提交于 2019-11-30 16:48:41
问题 I have a SQL Table and I would like to select multiple rows by ID. For example I would like to get the row with IDs 1, 5 and 9 from my table. I have been doing this with a WHERE IN statement similar to below: SELECT [Id] FROM [MyTable] WHERE [Id] IN (1,5,9) However this is quite slow for large numbers of items in the 'IN' clause Below is some performance data from selecting rows using where in from a table with 1,000,000 rows Querying for 1 random keys (where in) took 0ms Querying for 1000

Execute stored procedure with array-like string separated by comma [duplicate]

泪湿孤枕 提交于 2019-11-30 16:34:58
Possible Duplicate: Help with a sql search query using a comma delimitted parameter I want to write a stored procedure that performs a select on a table and need one input variable of type varchar(max) . I'd like to send a bunch of values separated by , as the input parameter, e.g. 'Jack','Jane','Joe' and then get the rows that contain one of these names. In SQL the code would be Select * from Personnel where Name in ('Jack','Joe','Jane'); Now I want to have a variable in my C# app, say strNames and fill it like string strNames = "'Jack','Joe','Jane'"; and send this variable to the SP and

How to enable “World Wide Services (HTTP)” in the firewall using command line?

[亡魂溺海] 提交于 2019-11-30 16:24:52
问题 I'm trying to share my site in the local network. I want to use command line tool to perform this action. Manually: To enable http access through Windows Firewall on Windows 7. From the start menu begin typing "Allow a program through Windows Firewall". Scroll the bottom of the list and look for World Wide Web Services (HTTP) and enable it on your networks. It works fine. Command line doesn't work: >> netsh advfirewall firewall set rule name="World Wide Web Services (HTTP)" new enable=yes

Bring SQL Server database online

时光毁灭记忆、已成空白 提交于 2019-11-30 14:01:44
问题 I executed the task Take offline of a SQL Server 2008 R2 database. I cant bring it online! I tried with USE master; GO ALTER DATABASE [DBNAME] SET ONLINE I get an error. User does not have permission to alter database 'DBNAME', the database does not exist, or the database is not in a state that allows access checks. I also tried using the task Bring online and I get the exact same error. Can anyone help me asap? 回答1: I think you're going to need to login with the SA account, or some other

T-SQL Is a sub query for an Update restriction Atomic with the update?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 14:00:10
I've got a simple queue implementation in MS Sql Server 2008 R2. Here's the essense of the queue: CREATE TABLE ToBeProcessed ( Id BIGINT IDENTITY(1,1) PRIMARY KEY NOT NULL, [Priority] INT DEFAULT(100) NOT NULL, IsBeingProcessed BIT default (0) NOT NULL, SomeData nvarchar(MAX) NOT null ) I want to atomically select the top n rows ordered by the priority and the id where IsBeingProcessed is false and update those rows to say they are being processed. I thought I'd use a combination of Update, Top, Output and Order By but unfortunately you can't use top and order by in an Update statement. So I

What is the best way to fetch records batch-wise from SQL Server

99封情书 提交于 2019-11-30 13:28:53
Scenario : we are fetching rows from SQL Server to C#.Net console application and doing action on the retrieved data from SQL Server through stored procedure; after the action is performed the new data is stored into the MongoDB using C#-MongoDB-Driver. Issue : There are billions of rows. My stored procedure contains query as follows: select * from table_name To work out some batch-wise logic there is no identity column nor any date columns or such. Information : As of now the application is fetching the records upto 3500 - 5000 records and storing into MongoDB and then it throws an error

How do I find the current version of a SQL Server data-tier application?

拈花ヽ惹草 提交于 2019-11-30 12:45:36
We are using a SQL Server Data-tier application (dacpac or DAC pack) and I'm having a hard time finding the current version of the database. Is there a way to obtain the current version using any of these methods: From within SQL Server Management Studio Via a SQL statement Programmatically using .NET code From within SQL Server Management Studio From http://msdn.microsoft.com/en-us/library/ee210574.aspx To view the details of a DAC deployed to an instance of the Database Engine: Select the View/Object Explorer menu. Connect to the instance of the from the Object Explorer pane. Select the View

How to query current user's roles

淺唱寂寞╮ 提交于 2019-11-30 12:37:40
I'm looking for a select statement which will retrieve a list of all database roles for my current connection. I want to create a view which will return all roles to a client software, such that the software can adjust its user interface according to the roles (e.g show/hide menu entries etc) You should not be using deprecated backward compatibility views ( search this page for sysusers , for example ). Instead, you should be using sys.database_principals and sys.database_role_members . Keep in mind that the current connection may have been granted access outside of the scope of the database

CTE very slow when Joined

偶尔善良 提交于 2019-11-30 12:14:50
I have posted something similar before, but I am approaching this from a different direction now so I opened a new question. I hope this is OK. I have been working with a CTE that creates a sum of charges based on a Parent Charge. The SQL and details can be seen here: CTE Index recommendations on multiple keyed table I don't think I am missing anything on the CTE, but I am getting a problem when I use it with a big table of data (3.5 million rows). The table tblChargeShare contains some other information that I need, such as an InvoiceID , so I placed my CTE in a view vwChargeShareSubCharges