sql-server

Remote connection to SQL Server Express fails

I have two computers that share the same Internet IP address. Using one of the computers, I can remotely connect to a SQL Server database on the other. Here is my connection string: SqlConnection connection = new SqlConnection(@"Data Source=192.168.1.101\SQLEXPRESSNI,1433;Network Library=DBMSSOCN;Initial Catalog=FirstDB;Persist Security...

how can i solve "The OLE DB provider "Microsoft.Jet.OLEDB.4.0" has not been registered."?

i try to use get excel data from excel file. i am using office 2007 and sql 2005. i writed below codes: CREATE TABLE [dbo].[Addresses_Temp] ( [FirstName] VARCHAR(20), [LastName] VARCHAR(20), [Address] VARCHAR(50), [City] VARCHAR(30), [State] VARCHAR(2), [ZIP] VARCHAR(10) ) GO INSER...

SQL Server Gender Swap Query

I have a Table having the following column: ID, Name, Designation, Salary, Contact, Address, Gender Accidentally for all male Gender i have entered 'Female' and similarly for all Female gender i have entered 'Male'. For Exmaple 0023 Scott Developer 15000 4569865 Cliff_Eddington,USA Female I the above line There should be Male inste...

SQL Server: query database user roles for all databases in server

I would like to make a query for database user roles for all databases in my sql server instance. I modified a query from sp_helpuser: select u.name ,case when (r.principal_id is null) then 'public' else r.name end ,l.default_database_name ,u.default_schema_name ,u.principal_id from sys.database_principa...

How to use a variable to specify filegroup in SQL Server

I want to alter a table to add a constraint during upgrade on a SQL Server database. This table is normally indexed on a filegroup called 'MY_INDEX' - but may also be on a database without this filegroup. In this case I want the indexing to be done on the 'PRIMARY' filegroup. I tried the following code to achieve this: DECLARE @fgName...

internal implementation of database Queries

In my experience I have used many queries like select, order by, where clause etc.. in mysql, sql-server, oracle etc For a moment i have thought, 1)how is this internally written to implement the above queries 2) which language do they use? 3) is that programming language? if yes which language? 4)what kind of environment required t...

Pros and Cons for CreatedDate and ModifiedDate columns in all database tables

What are the pros and cons? When should we have them and when we shouldn't? UPDATE What is this comment in an update SP auto generated with RepositoryFactory? Does it have to do anything with above columns not present? --The [dbo].[TableName] table doesn't have a timestamp column. Optimistic concurrency logic cannot be generated ...

ASP error 424 Object required

I've got a problem with the following code pasted below, the problem seems to be coming from the openastextstream this carries on from another question: Set str_text_stream = obj_file.OpenAsTextStream(ForReading, TristateUseDefault) response.Write "<table>" int_j = 0 int_x = 0 Err.number = 0 Do While Not str_text_stream.AtEndOfStream ...

SQL: Search and Replace part of string in all tables

Is it possible to search and replace all occurrences of a string in all tables of a database? ...

Can I encrypt value in C# and use that with SQL Server 2005 symmetric encryption?

To be more specific, if I create a symmetric key with a specific KEY_SOURCE and ALGORITHM (as described here), is there any way that I can set up the same key and algorithm in C# so that I can encrypt data in code, but have that data decrypted by the symmetric key in Sql Server? From the research I've done so far, it seems that the IDEN...

How can I attach a PDF file stored as binary object in SQL Server to an email?

I'd like to attach a PDF file stored as binary object in SQL Server to an email but without creating a (temporary) file on disk. I already have the first step to pull out the PDF file from the binary field in SQL Server as a byte[] array. Also I have the step to setup the MailMessage: MailMessage aMailMessage = new MailMessage(); // s...

Difference between Inner Join & Full join

What is the difference between a full join and an inner join? When I do a full join I get 832 records and with an inner join I get 830 records. ...

service broker message process order

Everywhere I read says that messages handled by the service broker are processed in the order that they arrive, and yet if you create a table, message type, contract, service etc , and on activation have a stored proc that waits for 2 seconds and inserts the msg into a table, set the max queue readers to 5 or 10, and send 20 odd messages...

Why use shorter VARCHAR(n) fields?

It is frequently advised to choose database field sizes to be as narrow as possible. I am wondering to what degree this applies to SQL Server 2005 VARCHAR columns: Storing 10-letter English words in a VARCHAR(255) field will not take up more storage than in a VARCHAR(10) field. Are there other reasons to restrict the size of VARCHAR fie...

How can I fill SQL Server table from excel only using sql query?

How can I do that with Microsoft.ACE.OLEDB.12.0? CREATE TABLE [dbo].[Addresses_Temp] ( [FirstName] VARCHAR(20), [LastName] VARCHAR(20), [Address] VARCHAR(50), [City] VARCHAR(30), [State] VARCHAR(2), [ZIP] VARCHAR(10) ) GO INSERT INTO [dbo].[Address_Temp] ( [FirstName], [La...

What arguments to use to explain why SQL Server is far better then a flat file

The higher ups in my company were told by good friends that flat files are the way to go, and we should switch from SQL Server to them for everything we do. We have over 300 servers and hundreds of different databases. From just the few I'm involved with we have > 10 billion records in quite a few of them with upwards of 100k new records...

What is the fastest way to get a DataTable into SQL Server?

I have a DataTable in memory that I need to dump straight into a SQL Server temp table. After the data has been inserted, I transform it a little bit, and then insert a subset of those records into a permanent table. The most time consuming part of this operation is getting the data into the temp table. Now, I have to use temp tables,...

Anyone know a program to automatically dump a bunch of test (dummy) data into a sql database?

Possible Duplicate: Tools for Generating Mock Data? I am running SQL Server 2005 and I want to dump some dummy data into a large table with about 50 columns (I did not design it :P) - anyone know a tool to do this automatically? I want the rows to have all sorts of different data, and I would rather not write a script if ther...

Flatten date range memberships retaining only the highest priority membership (TRANSACT-SQL)

Problem statement: A table contains an item_id, a category_id and a date range (begin_date and end_date). No item may be in more than one category on any given date (in general; during daily rebuilding it can be in an invalid state temporarily). By default, all items are added (and re-added if removed) to a category (derived from outsi...

SqlCE Flush Interval - Will the default setting lead to corruption?

SqlCE has a parameter set on the Connect String called Flush Interval. It is defined as: The interval time (in seconds) before all committed transactions are flushed to disk. If not specified, the default value is 10. I thought that a committed transaction, by definition, is a transaction that has been flushed to disk, specifically th...