sql-server

SQL server Timeout – only happens very occasionally

Hello, I have a web application that occasionally will throw this error…. Exception message: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. When I does I am unable to connect to SQL server, even through management studio, it’s says the server timed out and c...

Database Usage from Network Server

I am running desktop app that uses mdf file on local path.What if I want to do is that this mdf file should be placed over a network shared folder but network is using Domains and we need password to connect to that folder.Server is running windows Server and dont know if it has installed SQL Express or not. Q 1-> do server needs to hav...

Shared Data Sources vs. OLE DB Connections In SSIS

I've been using Shared Data Sources in all of my SSIS projects because I thought it was a "best practice". However, now that everything is under source control (TFS) just about every time I open a package it updates the Data Source connection in the package. I either have to roll the change back or check it in with some nonsense descri...

delete a record

Before I get into my question let me give you a little background on me first. I am a ASP programmer and I know enough about SQL Server (user side) to manipulate records to check my screens. As the title suggests, I am not able to delete a record from an sql table and I was able to about 2 months ago. About 6 months ago the DBA had t...

Change the Transactional Replication Distributor on SQL 2000

I have a server with about 3 replications configured. 3 databases being published to about 3 other servers there's a central Distributor I need to know if I can change the distributor for one of the publishings and let the others or if I can only change all of the replication distributors at the publisher server. And How to do this...

Entity Framework Invalid Object Name Error

I'm using VS2008 to connect to a SQL server database in order to populate it in C#. It's going pretty well, I'm able to query, insert, and update all tables in my database successfully, except one. Anytime I try to query or insert into one table I get the following error: Message = "Invalid object name 'DB_NewModelStoreContainer.DATATYP...

How to document database efficiently (tables, attributes with definition)?

We have a fairly large database (in SQL Server 2008) with many tables. We have just bought Red Gate's SQL Doc for documentation purposes. We would like to document this database in a detailed way. What is the best practice in documenting a database? How do you document your attributes with definitions? SQL Doc documents the database nice...

How to add row number column base on duplicated records that currently ordered

Hi, I want to insert a page_number in a record that continuously count base on duplicate in a column. example output: ID PAGE_ORDER PAGE_NUMBER 1 7 1 2 7 1 3 7 1 4 7 1 5 7 1 6 10 2 7 10 2...

Find Non-Ascii Characters in One Varchar Column or Mulitiple Columns using SQL Server

How can rows with Non-Ascii Characters be returned using SQL Server? If you can show how to do it for one column would be great. I am doing something like this now but it is not working select * from Staging.APARMRE1 AS ar where ar.Line like '%[^!-~ ]%' For extra credit, if it can span ALL VARCHAR columns in a Table would be outst...

ABOUT SCOPE_IDENTITY

SELECT SCOPE_IDENTITY is always resulting id=1, what i have done wrong? how to get the currentid of the inserted element. ...

How to create an index for Wildcard search on an Int Column in SQL Server ?

I've got a table with millions of rows. The PK of that table is an Int column. User wants to be able to do wildcard search on rows of that table by that PK. When doing this query the trivial way, it will be horribly slow, as Sql server does an implicit conversion of the column value from int to char in order to apply the wildcard every s...

Best free library in .NET to handle data in SQL Server ?

What is the best free library in .NET to : select, insert, update data in SQL Server with best performance (low level) launch stored procedure generate automatically object layer (1 object = 1 table) without relationnal link (foreign key is only id - 'int') I don't want to use EF (very bad performance) Thank you ...

Problem: we need to install SQL 2008 R2 Express with Management tools on about 24 physical machines of various OS flavors.

Problem: we need to install SQL 2008 R2 Express with Management tools on about 24 physical machines of various OS flavors. ...

Exporting CSV data using SQLCMD.EXE

I'm trying to export data from SQL Server into CSV format. I have a bat task to do this that's run at regular intervals. Command is: C:\Program Files\Microsoft SQL Server\[...]\SQLCMD.EXE" -d [db details] -i c:\export.sql -o c:\export.csv -s"," -W The SQL file is just a SELECT * from a view. This works except that some of the rows ...

Sql Server Script data: SMO.Scripter not working when output to file

I get this error message when I run the Powershell script at the bottom: Exception calling "EnumScript" with "1" argument(s): "Script failed for Table 'dbo.Product'. " At :line:48 char:35 + foreach ($s in $scripter.EnumScript <<<< ($tbl)) { write-host $s } However, when I comment out the output_file line #$output_file="C:\Product.sq...

Any alternatives to key word 'or' in an sql statement??

I probably didn't word the question right buy I have a query that is taking a substantial amount of time because of 'or'. select stuff from table1 T1 left join table2 T2 on T2.field1 = T1.field or T2.field2 = T1.field where some condition I have to check both fields to join. Is there a better way to do this? ...

select data from excel spreadsheet that's read only

I've got a dtsx package that selects data from an excel spreadsheet on the network and inserts it into a sql server table twice a day. However, the process fails if someone is in the spreadsheet modifying data. Is there a way to select data from an excel spreadsheet so that it doesn't fail if someone is in the spreadsheet? ...

Handling Images and file attachments in a Content Management System

Assumptions: Microsoft stack (ASP.NET; SQL Server). Some content management systems handle user-generated content (images, file attachments) by storing it in the file system. Others store these items in the back end database. Some examples of both: In the filesystem: Community Server, Graffiti CMS In the database: Microsoft Sharepoin...

SQL Server truncate table - drop and recreate FK constraints script

Hello, I'm writing small application (in c#) which helps me to truncate tables in SQL Server 2005/08. In order to truncate table I think I need to do this: drop all FK constraints from table, truncate the table, recreate all previously deleted constraints. Can someone help me to create such a script, or point me where I can find so...

What is the MS SQL Server capability similar to the MySQL FIELD() function?

MySQL provides a string function named FIELD() which accepts a variable number of arguments. The return value is the location of the first argument in the list of the remaining ones. In other words: FIELD('d', 'a', 'b', 'c', 'd', 'e', 'f') would return 4 since 'd' is the fourth argument following the first. This function provides t...