sql-server

Multi Rows Deletion from table in SQL Server

How I can Delete 1.5 Millions Rows From SQL Server 2000, And how much time it will take to complete this task. I dont want to delete all records from table.... I just want to delete all records which are fullfilling WHERE condition. EDITED from a comment to an answer below. "I fire the same query i.e. delete from table_name with Where...

How do I open a local SQL server database file outside of Visual Studio?

Is it possible to open a .mdf database file created in Visual Studio with some external SQL server IDE like Quest Toad for SQL server? Databases created in Visual Studio are rather similar to simple Access databases in that they're a single file. It appears external IDE's like Toad can't see the .mdf being served by my localhost's SQL ...

SQL Parent/Child recursive call or union?

I can't seem to find a relevant example out there. I'm trying to return a sub-set of a table, and for each row in that table, I want to check how many children it has, and return that number as part of the result set. Parent Table Columns: PK_ID, Column1, Column2, FK1 For each FK1 in result set, select count(*) from child_table. Fina...

How can I transfer database objects from a local database in App_Data Folder in a VS 2008 web app project to an SQL Server 2000 database?

We have a VS 2008 web application project under development for which a local database (mdf file) was created in its App_Data folder. Now we have changed our plans and decided to use a SQL Server 2000 Database instead of the file database in App_Data. To achieve this, I want to use DTS Import/Export wizard to move the local database obj...

Find path where SQL Server is installed?

How can I get the path where SQL Server 2005 is installed in a system, through SQL command? ...

SQL Server Globally Unique Identifiers

When or why will one need to use Globally Unique Identifiers instead of the traditional Idenity column? Please help me understand ...

One Cache for various Applications?

hi, i have two applications - one is an asp.net website and the other is a windows service. both applications are referencing my business layer (library project), which itself is referencing my data access layer (library project) that itself uses the enterprise library data application block to receive the data form a sql server 2005 d...

SQL Server and indices

Is it beneficial to add an index to a column that is part of a foreign key relationship? I have two columns which will be queried frequently and already have them foreign keyed but wasn't sure if I should index them aswell, or if the foreign key creates an index behind the scenes? ...

Can AWE use >4GB RAM on SQL Server 2005 dev edition on Windows XP 32-bit

Using SQL Server 2005 developer edition on Windows XP pro (32-bit) I notice that the check box to enable AWE (Advanced Windowing Extensions) is enabled. I have an Opteron workstation that I could easily upgrade to 8GB or more, although it is not practical to move off 32-bit Windows XP Pro for the development environment. As far as I ca...

Bulk insert, SQL Server 2000, unix linebreaks

I am trying to insert a .csv file into a database with unix linebreaks. The command I am running is: BULK INSERT table_name FROM 'C:\file.csv' WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR = '\n' ) If I convert the file into Windows format the load works, but I don't want to do this extra step if it can be avoided. Any id...

How to increment (or reserve) IDENTITY value in SQL Server without inserting into table

Is there a way to reserve or skip or increment value of identity column? I Have two tables joined in one-to-one relation ship. First one has IDENTITY PK column, and second one int PK (not IDENTITY). I used to insert in first, get ID and insert in second. And it works ok. Now I need to insert values in second table without inserting in...

Reporting Services - Convert 2008 Report Format to the 2005 Format

Is there any way to convert the 2008 Report format back to a 2005 format? I don't think I got prompted about my upgrading my reports and now I think they are in the new format. Any way to save my changes and go back a version? ...

Automatically print SSRS report?

Is there a way to automatically print a SQL Server Reporting services (2005) report? EDIT: We needed to print a SSRS report at a network printer programmatically. Specifically, we wanted to fire this off from a stored procedure. We are currently using likeabanshee's method, and it is working. However, we would like something more manag...

How do I get a count of items in one column that match items in another column?

Assume I have two data tables and a linking table as such: A B A_B_Link ----- ----- ----- ID ID A_ID Name Name B_ID 2 Questions: I would like to write a query so that I have all of A's columns and a count of how many B's are linked to A, what is the best way to do this? Is...

Select Parent Record With All Children in SQL

Let's say I have two tables, "Parent" and "Child". Parent-to-Child is a many:many relationship, implemented through a standard cross-referencing table. I want to find all records of Parent that are referenced by ALL members of a given set of Child using SQL (in particular MS SQL Server's T-SQL; 2005 syntax is acceptable). For example l...

How Can I Manage SQL Server Log Size

I'm trying to manage the size of a SQL Server 2008 log file. I have a reporting database that is loaded once a day. The Simple recovery model is the best fit as there are no transactions other than the morning load, and I can re-create those records. My goals are to have the transaction log at a fixed size, large enough that it doesn'...

SQL Licensing - Please help

We have 71 Branches, each branch have one SQL Server for Application and around 7-10 users who use AD user to login into Branch Application. They do not use any Database user. A single SQL Database user is shared by all users. Application internally manage the connectivity with AD user and in the application we have the option to give di...

SQL Server Stored Procedure Output Params in PHP

I need help running a stored procedure from SQL Server in PHP. PHP is running on a Unix/Linux server. We cannot get OUTPUT variables to return in PHP. The following is the PHP code: $conn = mssql_connect('server', 'user', 'pass'); mssql_select_db('db', $conn); $procedure = mssql_init('usp_StoredProc', $conn); $tmpVar1 =...

C# and SQL Server: Passwords. Where to do what?

Ok, I have an application written in C#. We have data in an SQL Server. Among that data we have user accounts, which will give access to the application. I've read around, and I know that you should salt and hash and possibly hash a bunch of times, etc. But, where do I do what? What do I send to and from the SQL Server? Exactly what do ...

T-SQL: @@IDENTITY, SCOPE_IDENTITY(), OUTPUT and other methods of retrieving last identity

I have seen various methods used when retrieving the value of a primary key identity field after insert. declare @t table ( id int identity primary key, somecol datetime default getdate() ) insert into @t default values select SCOPE_IDENTITY() --returns 1 select @@IDENTITY --returns 1 Returning a table of identities following...