sql-server

TSQL to Map User to Database

So I'm not able to user enterprise manager to do this... If I was I wouldn't even be asking this question. So I'm wondering if there is a way through TSQL to execute a command that maps a User to a particular Database and grants them 'owner' permissions. Thanks... ...

64-bit SQL Server Extended Stored Procedure cannot be called from 64-bit SQL Server

I have a (C++) 64-bit Extended Stored Procedure (XP) installed on 64-bit 2005 SQL Server on a 64-bit Windows XP machine. I can call its functions and it runs fine. However, I have a user who is unable to call the same XP on the same version of SQL Server on his 64-bit Windows 2008 Server machine. Checking the Event Viewer, he sees an e...

Is there a way to split the results of a select query into two equal halfs?

I need a solution for a select query in Sql Server 2005. I'd like to have a query returning two ResultSets each of which holding exactly half of all records matching a certain criteria. I tried using TOP 50 PERCENT in conjunction with an Order By but if the number of records in the table is odd, one record will show up in both resultset...

@@TRANCOUNT and a current connection

Assume I connect to SQL server 2008 via SQL Server Management Studio ( SSMS ) and open new window W1 by clicking on New Query tab and write the following inside W1: BEGIN TRANSACTION; If I execute this statement 5 times, and then write (inside W1) SELECT @@TRANCOUNT; , then the value returned will be 5. But if I open another window...

Is there any available free & open source implementation of RSA-2048 for SQL Server 2000?

I'm trying to do some cryptography for SQL Server 2000, and I know that only SQL 2005+ comes with built-in functionality for doing this natively. Do you know any open source implementation that I can use for free of RSA-2048 cryptography? ...

Sql Server performance

I know that I can't get a specific answer to my question, but I would like to know if I can find the tools to get to my answer. Ok we have a Sql Server 2008 database that for the last 4 days has had moments where for 5-20 minutes becomes unresponsive for specific queries. e.g. The following queries run in different query windows simul...

ERP system written in SQL Server, Trigger job not running

We are a manufacturing plant that runs off an ERP system written in SQL Server. I have never worked with SQL and therefore do not know the language. What I do know is that a trigger job that was running and updating data for us, is now NO longer running. Is anyone familiar enough to answer any questions about this for me??? Any help ...

SQL Server Constraints Across Tables

I have a SQL Server database with an Apartment table (which has columns FloorNum and BuildingID) and an ApartmentBuilding table (with column NumFloors). Is there any way to set up a constraint (using the SQL Server UI) to check that Apartment.FloorNum is greater than ApartmentBuilding.NumFloors? I tried this: FloorNum > ApartmentBuildi...

How to execute big SQL files on SQL Server?

I have about 50 T-SQL files, some of them are 30MB but some of them are 700MB. I thought on executing them manually, but if the file is bigger than 10MB it throws an out of memory exception on the SQL Server Management Studio. Any ideas? ...

SQL Server: ODBC Connection pooling / C API

I want to clarify how to do connection pooling with SQL Server from C, using ODBC. I know this question is, like.... sooooo 1998, but... I've never done it in C, so... here goes: First I think I have to set the attribute to enable pooling: rc = SQLSetEnvAttr( NULL, // make process level cursor pooling SQL_ATTR_CO...

SQL Server 2008 Spatial Clustering

I am trying to group points of geospatial data based on density and relative distance. Is there a way that this can be done in SQL Server 2008 using the spatial features or would it be better to translate the data into graph data and use a graph clustering algorithm? ...

Download all tables and stored procedures to file

Hi , is it possible to download in a file all the table definition(create Statements) and Stored Procedures from a SQL Server 2008 database? Thanks ...

How to insert Records to SQL/Server from Access to SQL/Server using "Insert Into" with slow connection

Here is what I tried. WHAT ELSE HAVE I MISSED OR SHOULD HAVE TRIED? My situation: SQL/Server in another country - direct Internet connection unreliable, private line cost-prohibitive, line condition changes constantly (ping 180 to 500+) Access SQL/Server via VPN connection - very slow but clean/reliable Access ACCDB (ace) database in...

In SQL Azure how what script can I use to create a read only user

I would like to create an Sql Azure user and grant her readonly access on a handful of DBs, what script can I use to achieve this? ...

MERGE statement attempted to UPDATE or DELETE the same row more than once

Getting following error with my merge statement Msg 8672, Level 16, State 1, Line 1 The MERGE statement attempted to UPDATE or DELETE the same row more than once. This happens when a target row matches more than one source row. A MERGE statement cannot UPDATE/DELETE the same row of the target table multiple times. Refine the ON clause t...

EF4 Generate Database

Hi, I am trying my hardest to find the simplest way to create a basic "model first" entity framework example. However I am struggling with the actually generation of the database, particularly the running of the SQL against the database. Tools Visual Studio 2010 SQL Server 2008 Express Process Create a new class project Add a ne...

Numeric Order By In Transact SQL (Ordering As String Instead Of Int)

I have an issue where I am trying to order a result set by what I believe to be a numberic column in my database. However when I get the result set, It has sorted the column as if it was a string (So alphabetically), instead of sorting it as an int. As an example. I have these numbers, 1 , 2, 3, 4, 5, 10, 11 When I order by in Trans...

How to figure the read/write ratio in Sql Server?

How can I query the read/write ratio in Sql Server 2005? Are there any caveats I should be aware of? Perhaps it can be found in a DMV query, a standard report, a custom report (i.e the Performance Dashboard), or examining a Sql Profiler trace. I'm not sure exactly. Why do I care? I'm taking time to improve the performance of my web a...

SQL conditional Pivot

Yes, this is another Pivot question... I've read through nearly all the previous questions and I can't seem to hack together a query that does what I need. Here is what my table looks like: FirmName Account Balance Pmt Revolving Installment Mortgage Amex 12345 10000 2000 1 0 0 Discover 54321 20000 4000 ...

Avoiding Nested Queries

How Important is it to avoid nested queries. I have always learnt to avoid them like a plague. But they are the most natural thing to me. When I am designing a query, the first thing I write is a nested query. Then I convert it to joins, which sometimes takes a lot of time to get right. And rarely gives a big performance improvement (s...