sql-server-2005

Importing csv file to SQL Server Management Studio - No tables available

I am trying to import a csv file to insert data into an existing table on my database. I go through the wizard and when it comes to select source tables and views for the destination, there are none to choose from. It just thinks I am trying to create a new table. Any suggestions? Thanks! ...

How can I see a login's default database?

Hi Stakoverflow, I need to detect a login's default database. Which system table/view should I query for that in SQL Server 2005? ...

Exec problem in SQL Server 2005

Hi, I have the situation where i have two databases with same structure. The first have some data in its data tables. I need to create a script that will transfer the data from the first database to the second. I have created this script. DECLARE @table_name nvarchar(MAX), @query nvarchar(MAX) DECLARE @table_cursor CURSOR SE...

Database Mirroring of SQL server

I have two databases that are mirrored to another server using database mirroring. The mirror server has to be down for some reason for few days. Now the production server is having principal databases in (PRINCIPAL/DISCONNECTED) State. Clients can access those databases. So what happens when they keep on adding data to these databases?...

How can i check sql server 'views' dependencies

Is there a way that i can find out what base tables are being used by views using a custom query or stored procedure? ...

SQL Server Views - INFORMATION_SCHEMA.VIEW_TABLE_USAGE

When i query INFORMATION_SCHEMA.VIEWS it list all views but when i query INFORMATION_SCHEMA.VIEW_TABLE_USAGE it displays only few views. How can i rebuild all the views info in INFORMATION_SCHEMA.VIEW_TABLE_USAGE? ...

Use SQL to filter the results of a stored procedure

I've looked at other questions on Stack Overflow related to this question, but none of them seemed to answer this question clearly. We have a system Stored Procedure called sp_who2 which returns a result set of information for all running processes on the server. I want to filter the data returned by the stored procedure; conceptually,...

How handle large dataset in asp.net

I have one dataset that contain at least 500 records. I add columns dinamically to that datast and fill new column using another dataset. this processes is very slow . I want to know how handle large dataset . how filter rows from large dataset. ...

Conditional Operator in SQL Where Clause

I'm wishing I could do something like the following in SQl Server 2005 (which I know isnt valid) for my where clause. Sometimes @teamID (passed into a stored procedure) will be the value of an existing teamID, otherwise it will always be zero and I want all rows from the Team table. I researched using Case and the operator needs to c...

to_date in SQL Server 2005

Does any one know how I would have to change the following to work with ms sql? WHERE registrationDate between to_date ('2003/01/01', 'yyyy/mm/dd') AND to_date ('2003/12/31', 'yyyy/mm/dd'); What I have read implies I would have to construct it using DATEPART() which could become very long winded. Especially when the goal would be to c...

Alter Sql table (Change foreign key to Second primary of the table)

Hi, I've a sql table with a primary key(Auto Incremented) and a foreign key.Now I need to modify the table by modifying the foreign key to second primary key so that its values are not allowed to duplicate. How do i alter my table without affecting the data? Need the sql code. Regards, Vix ...

what really are database Constraints?

What really is constraints? Why i need to know about them? What are the types of constraints? ...

sql server procedure optimization

SQl Server 2005: Option: 1 CREATE TABLE #test (customerid, orderdate, field1 INT, field2 INT, field3 INT) CREATE UNIQUE CLUSTERED INDEX Idx1 ON #test(customerid) CREATE INDEX Idx2 ON #test(field1 DESC) CREATE INDEX Idx3 ON #test(field2 DESC) CREATE INDEX Idx4 ON #test(field3 DESC) INSERT INTO #test ...

Saving formatted text from richtextbox

Hi, Is there any way, to save formatted in database from richtextbox? I've got richtextbox and some parts of text in this are bold. string s=richtextbox.Text obviously doesn't work. And If I can get this formatted text how to save it in Ms Sql Server 2005 ? ...

Problem with testing a Windows service

I want to make a Windows service that will access my database. My database is SQL Server 2005. Actually I am working on a website and my database is inside our server. I need to access my database every second and update the records. For that purpose I need to make a Windows service that will install into our server and perform the task...

how to validate the input parameters before using in the static query?? SQL server 2005

consider table1 with 2 columns.. table1: column1 int, column2 char create procedure SP1(@col1,@col2) as begin select * from table1 where _______ end Question: User may enter valid input for either (col1 or col2) or (both col1 and col2).so i need to validate the user input and use those correct column(s) in the satic query. ...

sp_addlinkedserver on sql server 2005 giving problem

I am trying to create a link server of a remote database(both the servers are SQL serve2005). I am able to connect that remote server from my SQL Server management studio. I used the following syntax to create it. EXEC sp_addlinkedserver @server = N'LINKSQL2005', @srvproduct = N'', @provider = N'SQLNCLI', @provstr = N'S...

Design ideas for a versioned db schema with related tables also versioned

Here is the drill, I want to version a database. I have done this before using multiple rows where the table primary key becomes a combination of the row id and either a datestamp or a version #. Now I want to version a table that depends on many other small tables. Versioning each table will be a giant PITA, so I am looking for goo...

retrieving description item from sql server table column

is it possible to retrieve by using connection.getschema() the description item from a sql server table column, just like it's possible to retrieve the column name, data type, is nullable, column default value, etc? if so, how? ...

Import xml to database with high end performance and Audit log- A best Practice

Hi, I have to import big xml files to Ms SQL 2005 Database by using C# with high end Performance. Even if any record fails in middle, i have to take next record for process and failed record need to log for audit. I don't want to put insert query with in for loop. Could you please suggest a best way to do this. If I can use bulkcopy ...