sql-server

Keeping referential integrity across multiple databases

What are the best practices for keeping referential integrity across multiple databases? since there's no built-in functions Or is it better to partition a single database? Update See kevin's example below. that is my situation. My inventory database has tables that reference the employeeId in the employees database. These databases a...

How to validate database backups

I have a few remote databases, hosted at my web hosts. For mysql, I use periodic mysqldump and for MSSQL, I use bcp to back them up. How do I validate those backups? How do I make sure that the backup was not partial (its done over the public network). ...

DB advice needed for performance of a 'SessionVisit' table

I have a 'SessionVisit' table which collects data about user visits. The script for this table is below. There may be 25,000 rows added a day. The table CREATE statement is below. My database knowledge is definitely not up to scratch as far as understanding the implications of such a schema. Can anyone give me their 2c of advice on som...

How do I use ROW_NUMBER() in SQL?

Hi, I want to use the ROW_NUMBER() to get... To get the max(ROW_NUMBER()) --> Or i guess this would also be the count of all rows I tried doing: SELECT max(ROW_NUMBER() OVER(ORDER BY UserId)) FROM Users but it didn't seem to work... To get ROW_NUMBER() using a given piece of information, ie. if I have a name and I want to kno...

TempDB full error

Hi, I have a web application running across a few sites, and last week I got a call to say they keep getting an error when accessing one specific page. The error is that tempdb is full, and i'm a bit stumped as to what to do about it. I've restarted the sql server (I'm led to believe this should re-create tempdb), but still the same pr...

Problem with handling COM events in VB.NET

I'm calling the SQLDMO 8.0 COM library from VB.NET (using a PIA I generated with tlbimp) in order to backup a database with percentage completion notification: Dim server As SQLDMO.SQLServer = Nothing Dim backup As SQLDMO.Backup = Nothing Dim restore As SQLDMO.Restore = Nothing Dim backupAbortable As Boolean Dim restoreAbortable As Bool...

LINQ not submitting changes

I'm using C# and LINQ to SQL I'm issuing the following command: User cu = CurrentUser; Post newPost = new Post { CreateDate = now, ModifyDate = now, User = cu, ModifyUser = cu, Text = text, Title = title, Thread = t, ResponseToPostID = null }; this.AppManager.DB.Posts.InsertOnSubmit(newPost); this.AppM...

Microsoft SQL Server, restore a backup of a database with one command

When we copy a database down from production, we make a backup of the database, zip it up and copy the backup down. Then we have to restore using the SQL Server GUI, which involves navigating through several menus and windows. As far as I know, you can not do this with SQL Server's built in stored procedures because you may not know the ...

SQL server managment studio Projects folder

Is there any easy way of changing the SQL Server Management Studio default 'Project' folder? I found one registry hack on the internet, but I'd rather not bother with that. I'm using SQL Server 2005 Express. ...

Storing SqlServer's raiserror message in C#

How can I store SQLSERVER's raiserror message in C# ? Thanks in advance ...

Can I export Word document(*.doc) from Reporting Service by using free component?

I'm looking for some tool that can generate many document formats like Microsoft Excel, PDF, Microsoft Word, HTML. So, I decide to use Reporting Service of SQL Server 2008 Express. But I found that Reporting Service can't export to Microsoft Word by itself. It need to use some component. Moreover, I can't find any free component to doing...

Join two column with the same number of row

Hi all, I want to combine 2 tables into one. Let say I have: Table1 ID Name 1 A 2 B 3 C Table2 ID Name 4 D 5 E 6 F I want to make Table3 Name1 Name2 A D B E C F How can I do this in SQL Server? Any help is greatly appreciated. ...

Check Procedures Performance

I would like to know the procedure which will give the out put about Name of the procedures and no.of reads in a perticular database,So that I can work on most read procuderes to improve the performance. Not with sql profiler,need tsql query to return all procedures and number of reads. ...

Why is my Primary Key slowing down my queries?

Hello, i'm using SQL Server 2008 and, in one of my tables, i implemented a (clustered) primary key on its identifier. Here's the table description: Identifier: - IdentifierId int NOT NULL PK - Alias nvarchar(200) - DataType int NOT NULL I made two indexes: one for Alias and another one for DataType. However, I just noticed somethin...

Flattening intersecting timespans

I have lots of data with start and stop times for a given ID and I need to flatten all intersecting and adjacent timespans into one combined timespan. The sample data posted below is all for the same ID so I didn't list it. To make things a bit clearer, take a look at the sample data for 03.06.2009: The following timespans are overlap...

Missing Path to SQL Server Express User Instance, can't see all databases in SQL Server Management Tool

I have a WPF application deployed via ClickOnce. This application uses a SQL Server Express database. I am trying to access my user instance of the database so that I can access the database that I am currently using when debugging so that I can verify writes to the DB made by entity framework. However, when I try to open the user instan...

Simulate enums in TSQL?

I recently accidently wrote a really ugly stored proc where I wished I had enums, Eg. CREATE PROCEDURE Proc_search_with_enum @user int, @account_category {enum} I understand that SQL 2000 doesn't have enums as a first class language construct, which coding conventions do you use to simulate enums or otherwise address the same issue?...

what is the minimum access level on a sql server the asp.net membership need?

for security reason, what is the minimum access level the asp.net membership user could have? ...

How do I take the results of multiple selects and combine into one row

hello, I have a table that contains information for 4 electrical generators I would like to have the results of the four querys in one row. does any one have a suggestion. Thanks SELECT avg(KW) as GEN_101_AVG FROM genset WHERE (GenSetName like 'GEA3519') and GenDate >= '1 jan 2003 00:00:00' and GenDate < '1 feb 2003 ...

ORM Recommendation for SQL Server

I am going to use SQL Server in my project, for that I want to select an ORM with it. I have some experience with NHibernate as an ORM. In fact, given the nature of that project ( MySQL the backend) NHibernate is really, the only choice. I have also used strongly typed dataset as my ORM, and that's having Microsoft Access as the backe...