Microsoft's SQL Server is a relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases. It originated from the Sybase SQL Server codebase, which is why both products use the extension of SQL called Transact-SQL (T-SQL).

learn more… | top users | synonyms (2)

1
vote
1answer
50 views

Merge Replicate, reinitialise with a different part of the data

I have a set of database with merge replicate configured between them. The publisher is an aggregate of three sets of data. Call them set 0, 1, and 2 There are subscribers that grab one set of the ...
14
votes
2answers
719 views

What are valid usage scenarios for HEAP tables?

I am currently doing some data imports into a legacy system and discovered that this system does not use a single clustered index. A quick Google search introduced me to the concept of HEAP tables and ...
7
votes
4answers
14k views

SQL Server database size didn't decrease after deleting large number of rows.

I'm no good in SQL, but I've got a database to maintain. There's almost no place left for it, so I've decided to delete all the data for, let's say, year 2008. After executing delete query (had ...
6
votes
1answer
272 views

AUTO_UPDATE_STATISTICS_ASYNC ON?

I have been advised that setting the AUTO_UPDATE_STATISTICS_ASYNC ON may be a good idea. I have been reading a couple of ideas and still not sure as this is a non default setting. Any further ...
1
vote
1answer
591 views

Audit 'sa' login in SQL Server 2005

I have a requirement where I need to audit (and potentially be notified) whenever the 'sa' user account logs into an SQL Server 2005 instance. Additionally, there is a preference that the database ...
0
votes
1answer
337 views

Is there a way to list all tables and when they were last accessed?

I'm wondering if there's a way in SQL Server to make a list of all tables and when they were last accessed (select / update / insert or delete) either by a user, view or stored procedure?
4
votes
1answer
426 views

Query to check where database growth was?

I have a database that grew very significantly overnight and I'd like to find out why. I've restored yesterdays backup to another location. Is there a query I can run to query the size of tables or ...
1
vote
0answers
48 views

Merge Replication Finding Session Id

I am using merge replication with SQL 2012. I am writing a custom business logic handler, and would like to know if there is a way to get a session id? For instance if the custom business logic ...
0
votes
1answer
9k views

user “sa” cannot connect to SQL Server Express 2008 R2

Goal: connect to SQL Server Express 2008 database using SQL Server authenticated account "sa", rather than my Windows authenticated account. When installing SQL Server 2008 Express, I took all ...
6
votes
2answers
8k views

SQL Server backup failing. Error: 3041, Severity: 16, State: 1

First of all, I'm very new at stackexchange, so please bear with me. I'm running a SQL Server 9.0.4060. My problem is: my SQL Server backup keeps failing on a lot of the databases. The Maintenance ...
6
votes
2answers
581 views

Adding a Clustered index to a HEAP table on someone else's app

We're using a proprietary application based on SQL Server 2005, which has many HEAP based tables (that is, no Clustered index). Over the years, these tables have grown badly fragmented (e.g. 99% ...
1
vote
1answer
133 views

a question in tables relations

Table A is linked to Table B , and Table B is linked to Table C using primary and foreign keys My questions: Should i link Table A to Table C too?? Or Table B can act as intermediate link between ...
2
votes
2answers
507 views

Executing query is too slow when accessing SQL Server located in an other country

I'am doing an investigation about a slow running query (see below info) when accessing our production SQL Server located in an other country. Now I'm looking for tweaks on how to solve this and make ...
4
votes
6answers
22k views

Download SQL Server profiler for SQL Server Management Studio

How can I profile a SQL Server 2008 database to see code that's being executed on a particular database? I remember using the SQL Server profiler, but I don't see it in SQL Server Management Studio ...
4
votes
1answer
649 views

MERGE with OUTPUT doesn't seem to be doing the right thing

I'm adding a foreign key to a table, and removing any rows that violate the FK, copying them into a ModifiedTable_invalid table. As part of the script, I've got the following MERGE command: MERGE ...
0
votes
1answer
316 views

Average, between specific date/time, of the difference between current field and previous field

Im trying to calc the average, between a specific date/time, of the difference between the current field and the previous field. At present ive got a query which displays this but im unsure how i can ...
3
votes
2answers
548 views

Save history editable data RDBMS

I want to make application like testing system. Every question has one or many variant of answers (and one or many can be right). I apologize that tutors and students use my testing system. It means ...
4
votes
4answers
7k views

How can I get the correct offset between UTC and local times for a date that is before or after DST?

I currently use the following to get a local datetime from a UTC datetime: SET @offset = DateDiff(minute, GetUTCDate(), GetDate()) SET @localDateTime = DateAdd(minute, @offset, @utcDateTime) My ...
5
votes
3answers
391 views

Database Indexing - Maintenance Jobs

I have created a script that runs every night to rebuild & re-organize indexes based on the fragmentation, Indexes with Fragmentation > 30% are rebuilt, Indexes with Fragmentation 10% - 30% are ...
4
votes
2answers
372 views

Best practise for copying a database from production

Currently after releasing a new major or minor version of our application, we take a copy of the production database and perform the below process: Copy production database to test server Obfuscate ...
1
vote
1answer
62 views

“max_packet_size” variant in SQL Server

I am wondering if there is a SQL Server "version" of the MySQL max_packet_size parameter. Is there a way to configure this setting in SQL Server?
0
votes
3answers
332 views

Pivoting row contents to produce one dimensional result

I have a table with a varchar column containing pipe-delimited values For example: Row 1 Column 1 = a|b|e|gg|foo Row 2 Column 1 = oV|foo|do Row 3 Column 1 = boop How can I query this to return ...
3
votes
3answers
185 views

PostgreSQL equivalent of SQL Server SQL_VARIANT_PROPERTY

Does PostgreSQL have an equivalent function for determining column metadata? Reference: SQL_VARIANT_PROPERTY pg_typeof() appears to be close, but it does not show the precision and scale. Looking up ...
3
votes
2answers
552 views

SQL ANSI JOIN precedence

I have a query that looks like this: SELECT * FROM TBLA A LEFT JOIN TBLB B ON A.Col1 = B.Col2 RIGHT JOIN TBLC C ON B.Col3 = C.Col4 JOIN TBLD D ON C.Col5 = D.Col6 In which order ...
4
votes
3answers
247 views

Storing date increments in tables

I'm working on a ASP/MS SQL project that performs a lot of calculations based on dates and time. In one case, the system will lookup a value based on the nearest half hour increment throughout the ...
1
vote
2answers
490 views

sql server removing service_queues

Hi when i query select * from sys.service_queues in sql server 2008 sp3 i am getting InternalMailQueue ExternalMailQueue _LakeSide_DbTools_DeadlockQueue QueryNotificationErrorsQueue ...
2
votes
1answer
1k views

SQL Server upgrade single instance

I have a server that is running SQL Server 2005 Express. It currently has 2 instances of SQL Server running. Instance 1 runs some old legacy software that is not supported by me. Instance 2 runs my ...
4
votes
1answer
366 views

SQL Server 2008 upgrade advisor tool

We upgraded to SQL Server 2008 from SQL Server 2000. But due to some legacy scripts/queries in our health care application, that run only in 2000, we had to run 2008 version on backwards compatibility ...
1
vote
1answer
3k views

Create a linked server with SQL Server 2012 x64

How can I create a linked server to a folder having fox pro dbf files? I can access the dbfs inside Visual Studio 2010, creating a connection with this properties Connection string ...
3
votes
1answer
3k views

Restore Backup Fails - File 'Db' cannot be restored to '{…}.mdf'. Use WITH MOVE to identify a valid location for the file

I am getting the following errors trying to do a restore using the restore command on a backup file I recieved from a customer. RESTORE DATABASE SFDB FROM DISK = N'C:\Backup\Backup.bak' Any ...
0
votes
2answers
271 views

SQL Server 2005 replication for a data warehouse

We are trying to implement some kind of Data Warehouse at my current employer. Most of our data is in a SQL Server 2005, but we might also integrate some Access databases and some databases in a SQL ...
3
votes
0answers
204 views

Why is my CPU usage increase after setting database to read-only on SQL Server 2008 R2

I administrate a reporting database. We run all the denormalization process on a DB1 daily then we copy all the data to an another database DB2 on the same server which is queried by web applications ...
0
votes
1answer
151 views

How to understand what Columns Have Changed in Merge Replication

I am using merge replication in SQL 2012. Some of my merge articles use column level tracking. I am trying to understand how to use the 'lineage', and 'colv1' fields in the MSmerge_contents table to ...
3
votes
1answer
4k views

How to grant a user UNSAFE ASSEMBLY permission

How can we assign a user , e.g.: the database owner (DBO) the UNSAFE ASSEMBLY permission? I'm asking it to enable a user to create an assembly and don't know the SA password, so EXEC sp_changedbowner ...
1
vote
1answer
833 views

Converting ZIP code string to integer in SQL Server

I have a SQL Server table pairing zipcodes and lat/long geometry, such as below ID ZIP5 geom 1 356HH 0xE610000001044E00....FFFFFFFF0000000003ID 2 35677 0xE6100000010404000000068....000003 ...
4
votes
1answer
114 views

What is a good auto-generated key for a federated database?

I am about to split a large database into a bunch of federated instances. Currently, most of the primary keys are auto-generated identity ints. Obviously, that's not going to work in a federated ...
3
votes
2answers
1k views

Does adding page compression to a table also compress existing indexes?

I am creating a series of new tables that will have page level compression enabled. Will this affect the indexes as well, or will I have to also specify compression when creating the indexes? create ...
3
votes
1answer
343 views

TempDB size issue after applying Indexes

I added several indexes to a SQL Server 2012 database to help with performance a couple of days ago. Today our partition with TempDB on it ran out of space. TempDB went from less than 10 GB to 38 GB. ...
0
votes
1answer
107 views

seeking a confirmation — SQL Server backup performance [duplicate]

Possible Duplicate: Is SQL Server Backup single or multi-threaded? Does SQL Server uses a separate writer thread for each backup device (backup file) or separate thread is used only when ...
2
votes
1answer
408 views

Migrating database from SQL Server 2005 Enterprise to SQL Server 2008 Standard

I'm attempting to migrate a database from SQL Server 2005 Enterprise to SQL Server 2008 Standard. I've run into an issue because there is a partition function defined in the database of the Enterprise ...
0
votes
1answer
89 views

UTC date in DMV dm_broker_queue_monitors

It seems that the DMV dm_broker_queue_monitors returns UTC time rather than local time. Why is it so? I am wondering how to get local time from this view? I can get current time offset, but that is ...
1
vote
0answers
101 views

MS SQL to MySQL Conversion

Is there a tool available that converts queries written as triggers, stored procedures and functions written in MS SQL 2008 to MySql? We switched databases and now I need to rewrite a bunch of queries ...
8
votes
1answer
130 views

How can I prevent SSMS from re-writing my code when saving a view?

I'm creating a view that uses a statement with a WHERE clause similar to this: WHERE ( col1 IS NOT NULL OR col2 IS NOT NULL ) AND NOT EXISTS (SELECT ...) ...
5
votes
3answers
823 views

Storing terabytes of data in SQL Server

I need to develop a production system capable of storing a 100 kb textfile and a serial number for every piece produced. I know the approximate output over 2 years, the time the data has to be stored, ...
12
votes
2answers
458 views

SQL Server 2008 Performance issue with very strange resolution

I'm a long time DBA (12 years in SQL). I'm running SQL Server 2008 Enterprise in a Win 2008 clustered environment. 128gb memory and 32cpu in each cluster node. Not wimpy. I've got the weirdest ...
5
votes
2answers
370 views

Why does OBJECTPROPERTY return NULL?

Say you want to query a database to discover the types of trigger it contains. One way to do this is to use the OBJECTPROPERTY function on all trigger objects in the database. Sometimes the ...
2
votes
1answer
215 views

UDF performance suddenly degraded

SQL Server 2008 R2 I know this is a common problem (eg: http://connect.microsoft.com/SQLServer/feedback/details/524983/user-defined-function-performance-is-unacceptable) - but ive only just learned ...
1
vote
1answer
87 views

Partitions and Indexes, in which cases should be used

I know some knowledges: Partitions used to achieve better performance (like described in this article) And indexes used to increase performance in selection operations. And as result my question: ...
1
vote
0answers
61 views

i want to modify Redgate source control Git.xml file to include commit and push

Below is an excerpt for the git.xml file in redgates source control <element> <key type="string">Commit</key> <value version="1" type="GenericHookCommand"> ...
2
votes
1answer
493 views

Index with multiple leaf levels

I have a three-column (int, smallint, smallint) composite clustered index with three leaf levels. My question is how and when does SQL Server create multiple leaf levels (index_level 0) for the same ...