sql-server

Is there a way to create subdatabases as a kind of subfolders in sql server?

I am creating an application where there is main DB and where other data is stored in secondary databases. The secondary databases follow a "plugin" approach. I use SQL Server. A simple installation of the application will just have the mainDB, while as an option one can activate more "plug-ins" and for every plug-in there will be a new...

What kind of encryption mechanisms does SQL Server 2008 Standard offer?

As I see, TDE and EKM mechanisms are available only in Enterprise edition. How can I encrypt data in tables in Standard edition of SQL Server 2008? ...

SQL-Server: Impersonation

Hello, is there any way to make a certain session execute all commands as a certain user? I cannot use the execute as clause because it mustn't be hardcoded. I need something along the lines of this pseudocode: ALTER SESSION sessionid SET EXECUTING_USER=someuser ...

Pass tenant id via sql server connection

Hi guys, I'm building multi tenant application with shared table structure using Microsoft SQL Server. I wonder if it possible to pass tenantID parameter via sql server connection. I don't want to create separate user account for each tenant. Currently I see two ways: via ApplicationName or WorkstationID Best regards, Alexey Zakharov...

sqlsrv_connect() not found..

Hey, I recently am working on an projekt that uses the "SQL Server Driver for PHP", i wanted to upgrade the existing driver to the new version (2.0), because I need some of the functions that have been implemented there. Now i replaced the old .dll in the php/ext directory and restarted the webserver. But now i recieve the following er...

NOT IN statement for Visual Studio's Query Builder for TableAdapter

Hi I want to realize a query with the Visual Studio 2008 build in Query Builder for a TableAdapter similar like following (MSSQL 2008): select * from [MyDB].[dbo].[MyView] where UNIQUE_ID NOT IN ('MyUniqueID1','MyUniqueID2') How do I have to set the Filter in my query in order to call it with the myTableAdapter.GetDataExceptUniqueIds...

Help me with DB design

Hi, i'm developing text ads system. Some small clone of Google Ads Updated image so all field names would be seen if you don't seen diagram, click here Here is diagram with common tables. Basically make it short, advertiser can have up to 10 variant of same campaign with different text variations, can geo-target his ads and unique im...

Problem with nvarchar data with XML in SQL server 2005

Create table testxml (xmldata xml) declare @var nvarchar(max) set @var = N'الوفاق الوطني المخ' insert into testxml select @var After inserting , i am getting data from table like select * from testxml --------------------- ???????? Can you provide me the solution? ...

Limit the number of rows returned on the server side (forced limit)

So we have a piece of software which has a poorly written SQL statement which is causing every row from a table to be returned. There are several million rows in the table so this is causing serious memory issues and crashes on our clients machine. The vendor is in the process of creating a patch for the issue, however it is still a fe...

SQL Script To Generate a Database Dictionary **With Linked Fields**

I would like to generate a Data Dictionary for a SQL Server 2008 database that has one row for each field, and the following columns: table_name field_name data_type link_table (for when the field in question is a foreign key) link_field (for when the field in question is a foreign key) I can get the first 3 columns with something like...

SQL Server CLR stored procedures in data processing tasks - good or evil?

In short - is it a good design solution to implement most of the business logic in CLR stored procedures? I have read much about them recently but I can't figure out when they should be used, what are the best practices, are they good enough or not. For example, my business application needs to parse a large fixed-length text file, ...

DB Interface Design Optimization: Is it better to optimise for Fewer requests of smaller data size?

The prevailing wisdom in webservices/web requests in general is to design your api such that you use as few requests as possible, and that each request returns therefore as much data as is needed In database design, the accepted wisdom is to design your queries to minimise size over the network, as opposed to minimizing the number of qu...

How do you set up a Report Server instance?

Hi, I'm trying to set up Microsoft SQL Server Reporting Services. I open the Reporting Services Configuration Manager, and it asks for a Server name. Thing is, I don't know the server name, because as far as I know haven't set a report server up yet. So, how do you set one up for Microsoft SQL Server 2008 R2? There seems to be plenty of ...

complex Subtract in sql server query

Hello, I have table like following PK num1 num2 numsdiff 1 10 15 ? 2 20 25 ? 3 30 35 ? 4 40 45 ? i need to get Subtract of 20 - 15 and 30 - 25 and 40 - 35 and so on by select query from this table. any ideas?. thanks ...

How do I list all tables in all databases in SQL Server in a single result set?

I am looking for T-SQL code to list all tables in all databases in SQL Server (at least in SS2005 and SS2008; would be nice to also apply to SS2000). The catch, however, is that I would like a single result set. This precludes the otherwise excellent answer from Pinal Dave: sp_msforeachdb 'select "?" AS db, * from [?].sys.tables' The ...

Database maintenance, big binary table optimization

Hi i have a huge database, around 1 TB in size, most of the space is consumed by a table which stores images, the tables has right now almost 800k rows. server response time has increased, i would like to know which techniques should i use or you recomend, partitioning? o how to reorganize the table every row is accessed by the image ...

Performance when querying a View

I'm wondering if this is a bad practice or if in general this is the correct approach. Lets say that I've created a view that combines a few attributes from a few tables. My question, what do I need to do so I can query against this view as if it were a table without worrying about performance? All attributes in the original tables ...

Integrated Windows authentication in IIS causing ADO.NET failure

We have a .NET 3.5 Web Service (not WCF) running under IIS. It must use identity impersonate="true" and Integrated Windows authentication in order to authenticate to third-party software. In addition, it connects to a SQL Server database using ADO.NET and SQL Server Authentication (specifying a fixed User ID and Password in the connectio...

Is there an SQL Server equivalent to Oracle's RETURNING statement?

Is there an SQL Server equivalent to Oracle's RETURNING statement? I'm wondering if the OUTPUT clause would help. ...

SQL Server Transactions how can I commit my transaction

I have SQL Server 2005 stored procedure. Someone one is calling my stored procedure within a transaction. In my stored proc I'm logging some information (insert into a table). When the higher level transaction rolls back it removes my insert. Is there anyway I can commit my insert and prevent the higher level rollback from removing my i...