sql-server-2005

Heavily fragmented Indexes - SQL Server 2005

I recently inherited a poorly maintained production database with heavily fragmented indexes (most of the indexes with more than 80% fragmented). I requested downtime with my manager to perform Index rebuild, but unfortunately downtime is not allowed at the moment. If online Index reorganize too is not option, can I do the following? R...

Asp.net app_data folder contains db.

I am using VS 2005 I am new to asp.net i have a project created in asp.net c# which is using sql server express edition local database. there is a app_data folder there is *.mdf file inside i can see it also i can browse the tables from it. In app data folder i can see there are few .sql scripts named CreateAllObjects.sql DeleAllData...

SQL Deadlock question

Is it possible in relational databases for these two statements to deadlock? I'm trying to simplify my question and example -- please just assume that these selects, which I think would normally only require sharable read-locking, now require exclusive read locks: Concurrent Connection 1: SELECT {...} FROM A JOIN B ON {...} Concurren...

Visual Studio 2005 SQL Server Express edtion username pass

Visual Studio 2005 I connect with SQL Server Express edition with SQL Server Management Studio Express using Windows authentication. When I installed Visual Studio 2005 I didn't get asked for SQL Server Express edition user name or password. How can I connect without Windows authentication ? ...

Can SELECTING FROM one empty temp table in SQL cause the results to be empty?

Here is my problem. I am creating 4 temp tables to count specific types of boxes and an employee's hours. Given a beginning date and ending date we want to know total boxes of each type (1, 2, and 3) and their total hours worked in that time period. All works perfectly if there is at least one of each type, but if only two types are pres...

SSIS storing logging variables in a derived column

I am developing SSIS packages that consist of 2 main steps: Step 1: Grab all sorts of data from existing legacy systems and dump them into a series of staging tables in my database. Step 2: Move the data from my staging tables into a more relational set of tables that I'm using specifically for my project. In step 1 I'm just doing a...

Can SQL Server 2008 Express be installed with SQL Server 2005 Standard

I know SQL Server 2008 Express can be installed side by side with SQL Server 2005 Express, but but am not sure, and have not found any useful posts about if it is possible to install SQL Server 2008 Express along side a SQL Server 2005 Standard install. Thanks! ...

SQL CLR how to access username, hostname, and app_name running in safe mode

I have a trigger written in sql clr (sql 2005, .net 3.5) and I need to get at username, hostname and app_name. In TSQL I would simply use select suser_name() select host_name() select APP_NAME() In my .Net code I tried System.Security.Principal.WindowsIdentity.GetCurrent().Name System.Environment.MachineName System.AppDomain.Current...

SQL Server - Copy stored procedure's from one database to other

I am trying to copy a database with huge data from SQL Server 2005 to SQL Server 2008. I tried using the Copy Database Wizard but could not use the wizard because they are two different server 2005 and 2008. So I copied all the tables using Import data wizard from SQL Server 2008. I had about 1120 stored procedures to be copied, so on ...

Problem Setting Foreign Key

I am trying to set a foreign key relationship between an Order_Items table and Parts table. I want to link the parts to products in the Order_Items table via foreign key. I have no issues doing this with other tables. Here is how the Order_Items table is defined: CREATE TABLE [dbo].[Order_Items]( [order_id] [uniqueidentifier] NOT N...

Error opening .mdf file through SQL Server Management Studio Express

I am doing a project of a web enabled database. I have created the database file in my PC. Now when I just want to open .mdf i.e. of the database I created, I cannot open it in other PC. I even had copied the .ldf file i.e the log file to that PC. Since I need to transfer the database to the Server later, I don't know how I will dump t...

SQL 2005 Update - number of counts issue

I am using SQL 2005. When i am selecting a set rows from the table with the appropriate where condition, it return value as 31. The same select value if i update to another table it is updating as 30. i used the SQL update as follows update tablename set column1 = (Select column2 from tablename where month(field1) = 05 and year(field1) ...

sql server management studio problem.

hello friend on w7 i configured my sql sever and ssms but while going through ssms it's producing following error...please resolve my problem. TITLE: Microsoft SQL Server Management Studio Express The database model is not accessible. (Microsoft.SqlServer.Express.ObjectExplorer) ...

get the hours for every month

Hi Guys, I have created a function which will take two parameters as startdate, enddate and returns hours from that. here i am getting both the total hours but i need to get individual month hours from that. Regards, kumar ...

SQL scramble database varchar fields

Hi, I have to create a test database for some external developers to use. We have created a copy and rather than manually filling it with junk data i want to scramble the text fields. Are there any easy ways of doing this? Im using sql server 2005 Sp ...

With CTE is same like temp tables ?

Hi all, I am using "WITH CTE" inside my trigger. So if many users came into my web app, does the performance will be slow. Droping will be automatically happen. Will creation and droping of CTE is more costlier. Is is advisable? How much can i store using WITH CTE? Is it same like TEMPORARY TABLE? ...

Order BY in SQL

In my SQL statement, need to parse a title field so I can order by the integers. Basically, just extract the integers into a new field and order on that field. the data in the title field looks like the following (WRONG): TT TEST 750-1 TT TEST 80-1 TT TEST 1 UU 25-1 TT TEST 1 UU 420-1 TT TEST 1 UU 55-46 TT TEST 1 UU 600-8-10 TT TEST 1 ...

Creating a SQL Server user with permission to read one view and nothing else - but he can see system views and procedures?

My company hired a contractor to do a small project for us, for which he needs to select data from one single view in our main database (SQL Server 2005). I wanted to create a locked-down SQL Server login for him, with permissions just to SELECT from "his" view...and nothing else. So I created a new user on the server, and then I gav...

sql set operation and where clause

Hi all Is it possible to have a query like this (I'm getting error) : SELECT ColumnA FROM Table1 EXCEPT SELECT ColumnB FROM Table2 WHERE Table1.ColumnC = Table2.ColumnC SQL can't bind the Table1.colmnC in my where clause . is there any way to run this query ? or another way to get the same result ? I know that I can do this using tem...

how to split and insert CSV data into a new table in single statement?

I have a table named "Documents" containing a column as below: DocumentID I have data in the format - @DocID = 1,2,3,4 How do I insert these documentID's in separate rows using a single query? ...