sql-server

SQL replication - Publication deleted, but log file still growing

To preface, I've seen the command to answer this question before, but now I can't find it again, so I'm just looking for the single SQL statement that will solve my problem. I had two publications on a SQL Server 2000 database at one point, but I've since deleted them. However, my log file is growing, and appears to contain unreplicated...

Sql Trigger - which table does it belong to?

Is there a way within a Sql Server 2005 Trigger to get the name and schema of the table that the trigger is attached to during execution? ...

Using constants in SSRS's Error Bar Chart

I have a SSRS 2008 report with a Error Bar chart. It plots dates (x-axis) versus score (y-axis), with +10/-10 for the upper/lower error range. But in the dataset, I also have two sets averages (the US and the company's). I would like to display these averages as a constant. It should be a horizontal line that runs through the chart. ...

Use variables expansions in schema in sql server 2005 / 2008

I am trying to create stored procedure which will decide which language to use based on a parameter passed? How can I do something like this ? declare @en varchar(50) = 'en' declare @fi varchar(50) = 'fi' select * from [@en].[TestingLanguagesInNameSpacesDelMe] select * from [@fi].[TestingLanguagesInNameSpacesDelMe] ...

Copying a set of records with constraints, with common ancestor.

I have a set of tables that's actually a stubby tree. At the top, there's a Customer, and below that Invoices, and Invoice Detail records. (In actuality, there's about two dozen of these tables all referring to the Customer but the principle should apply with just three tables.) What I'd like to do is to copy the Customer and all of t...

SQL Server 2008 Web Edition

Can somebody give me some info on SQL Server 2008 Web Edition? Is this a new edition with 2008? What kind of limitations does it have? Is anybody using it successfully? What does it provide that the Express Edition won't? ...

how to find missing value in sequence within groups in SQL?

i have a table of IDs and positions CREATE TABLE #MissingSequence (ID INT NOT NULL, Position INT NOT NULL) INSERT INTO #MissingSequence (ID,Position) SELECT 36,1 UNION ALL SELECT 36,2 UNION ALL SELECT 36,3 UNION ALL SELECT 36,4 UNION ALL SELECT 36,5 UNION ALL SELECT 36,6 UNION ALL SELECT 44,1 UNION ALL SELECT 44,3 UNION ALL SELECT 44,4 ...

How to use variable for database name in t-sql

I use the database name in several places in my script and I want to be able to quickly change it, so I'm looking for something like this: DECLARE @DBNAME VARCHAR(50) SET @DBNAME = 'TEST' CREATE DATABASE @DBNAME GO ALTER DATABASE @DBNAME SET COMPATIBILITY_LEVEL = 90 GO ALTER DATABASE @DBNAME SET RECOVERY SIMPLE GO But it doesn't wor...

select statement to return the column names in a table

Is there any select statement to return the list of columns in the table? ...

Disable Foreign key constraint on a table?

Can i temporaryly disable a foreign key constraint. How do i do this? ...

ASP.NET MVC "Stock Application" Deployment Issue

I am starting to learn ASP.NET MVC. I have deployed the "stock" ASP.NET MVC Sample Application (i.e. the simple user account system) to have a live version to test against when I start to play. Note that I'm using: - ASP.NET MVC 1.0 release. - WebFusion Host. I think the issue is to do with accessing the database. I deployed usin...

Creating SQL Server backup file (.bak) with c# to any location

Hello all! I'm trying to write simple application in C# which will allow me to backup, zip and send over ftp my SQL Server database. One problem I have encountered is that I'm not able to create the backup file (.bak) if I try to do it in different location than "C:\Program Files\Microsoft SQL Server\MSSQL.3\MSSQL\Backup" or "C:\Program...

How to restore a SQL Server 2005 DB from a local .BAK-file?

I need to restore a DB from a .BAK-file that is not located on the server, but on my local machine. Normally I remote desktop to the SQL server, copy the .BAK-file, and do the restore that way with Management Studio. This feels a bit awkward though, especially on days like this, when I get thrown out because the number of allowed connec...

SQL Express User Instance with multiple ASP.NET Sites

How can I get two separate ASP.NET sites, in this case a Web Site using Entity Framework and Web Service, to use the same local database mdf & ldf? I looked around and I think that this kind of local DB is called a User Instance - at least they way I'm currently using it. I wasn't sure if it would work or not until I found the below in...

SQL exclude a column using SELECT * [except columnA] FROM tableA?

We all know that to select all columns from a table, we can use SELECT * FROM tableA Is there a way to exclude column(s) from a table without specifying all the columns? SELECT * [except columnA] FROM tableA The only way that I know is to manually specify all the columns and exclude the unwanted column. This is really time consumin...

How to pull data from one database to another database using sqlsqerver 2005

How to pull data from one database to another database by using sqlsqerver 2005 like ..Exporting data from one and importing to the another. ...

Sql table unresponsive when selecting or counting all rows

We have a table in a database that has 35 rows, according to exec sp_spaceused Department. I am able to run SELECT TOP 1 * FROM Department, and get a result, but when I run SELECT COUNT(*) FROM Department, it runs longer than 2 minutes (I then cancelled it and did not wait for a result, since I expect this to be a simple and fast...

Eliminate partial duplicate rows from result set

Hi, I have a query that returns a result set similar to the one below (in reality it is far bigger, thousands of rows): A | B | C | D -----|----|----|----- 1 NULL | d0 | d0 | NULL 2 NULL | d0 | d1 | NULL 3 NULL | d0 | d2 | a0 4 d0 | d1 | d1 | NULL 5 d0 | d2 | d2 | a0 Two of the rows are consi...

how can i add select query result into dataset later again select query run...

i want to add select query result into dataset, so i can write new query to run on it to get net dataset but how? Original query: MyDATASET=( select x, y,z from table1 union all select k,l,m from table2 ) i wan to this select * from this.MyDATASET ...

SQL server profiler not showing LINQ To Sql queries

I am trying to view SQL generated by Linq to SQL in the SQL Server Profiler (2005). I can see the sql sent to the server from anything except for linq to sql. I'm betting that I need to change event selections for the trace, but not sure what else to select. I am currently only selecting this: SQL:StmtCompleted - TextData & SPID I do...