sql-server

In tsql is an Insert with a Select statement safe in terms of concurrency?

In my answer to this SO question I suggest using a single insert statement, with a select that increments a value, as shown below. Insert Into VersionTable (Id, VersionNumber, Title, Description, ...) Select @ObjectId, max(VersionNumber) + 1, @Title, @Description From VersionTable Where Id = @ObjectId I suggested this because I b...

Can anybody explain SQL Server 2005 table size.

I'm working with SQL Server 2005 and have a single table: int Code1, int Code2, real Val1, real Val2, real Val3, Code1 & Code2 serve as a primary key and are part of the clustered index (only one index). Each parameter occupies 4 bytes (each row occupies 20 bytes). There are 24.5 million records in the table, fill factor is 100%, th...

SQL Server 2005 import a csv file , rows in correct order

I use SQL Server wizard to import csv files, however the rows imported appears in different order. How can I say to SQL Server to import rows in correct order. ...

There is insufficient system memory in resource pool 'default' to run this query.

I'm getting this error: There is insufficient system memory in resource pool 'default' to run this query. I'm just running 100,000 simple insert statements as shown below. I got the error approx on the 85,000th insert. This is a demo for a class I'm taking... use sampleautogrow INSERT INTO SampleData VALUES ('fazgypvlhl2svnh1t5di','...

Create a SQL Database locally

I'm looking to learn ADO.NET and such with SQL. However, i'm at home for the winter so I'm away from my school's servers which were configured already. I'm looking to run something like a local sql server and databases to just practice and learn with. I downloaded and installed MS SQL Server 2008 Express, but I don't know what to do with...

SQL Server stored procedure

Is it possible to write stored procedure that works with a variable number of parameters? (in SQL Server 2005) ...

Saving data in SQL Server, the right approach

We have internal application used to publish articles, using SQL Server 2005. For the task I need to save list of tags when a user publishes a post. Should I make a separate table For Tags and update the ID column for a TAG with the id of the post that lists it, using XML column like TABLE_TAGS TAG_NAME varchar, ARTICLE_IDS XML OR ...

TSQL in SQL 2005: Query

I have 2 columns in my table, called TaskSet and SkillsSelected. The sample data as follow: TaskSet | SkillsSelected -------------------------------------------------- SK000001, SK000004, SK000002 | SK000001, SK000002, SK000003 SK000002 | SK000002, SK000003, SK000004 As you can see it's ...

Custom PrimaryKey Generation with autoincrement

I need to define and generate primary key for 2 or more tables. Tables hold same type of data but FOR Some BUSINESS RULES we have to make them separate say like TableA = LOCAL_CUSTOMERS TableB = INTERNATIONAL_CUSTOMERS Both hold same columns like, CUSTOMER_ID C_NAME, CITY ....etc While designing the Primary Key I want these keys to b...

Is a 3 (physical) tier architecture inefficient?

Note: When I refer to tier, I mean a physical tier. Many of the questions on this site relating to "tiers" are referring to logical layers, which is not what I'm asking about. I am designing an app using a standard "3 layer" architecture, with presentation, business logic (BLL) and data access (DAL) layers. The technology is WPF, C#, LI...

sql query, returning table or table row?

In my web application I write a query to check the userid and password. If userid is failed I write the query that it display userid is wrong if password is wrong then it display password is wrong. The query I write just returns int, but I want to return table or data row can you give me a solution? This is my query: user table consist...

Getting a driver for VMS to connect to SQL Server 2005

I want to connect from a COBOL/VMS system to an SQL Server 2005 instance. Could someone point me to a driver that works well? ...

sql Merge databases.

Hi I have a Databse "Product" in in sql 2008.I have another Databse "ORDER" in sql 2008. Both exist in different servers. Now the requirement is to Merge both databases, and test pointing the applications to this new DB. Can anyone suggest the best way to accomplish this without losing the information? I have 2 options. 1) Script th...

Stored procedure?

I write a stored procedure for most viewed photos in my procedure, this is my procedure can u check this please is ok or is there any improvement required? create procedure sp_photos_selectmostviewedphotos as select * from photos order by views desc is it enough or required any modification ...

dbExpress and SQL Server 2000 problem

I’m using the new C++ builder 2010 and I’m upgrading a c++ program from c++ builder 6. I have a case sensitive data database (SQL Server 2000) using the collation SQL_Latin1_General_CP1_CS_AS I’m moving the data components from BDE to dbExpress. Using profiler I can see that when the components query systables / get Meta data its searc...

Update stored procedure?

I write stored procedure for update. create procedure sp_videos_updateviews (@videoid varchar(50),@ret int output) as set @ret = update videos set [views]=[views]+1 where videoid = @videoid if(@ret>1) begin set @ret=1 end else begin set @ret=0 end but it is giving error like this Incorrect syntax n...

How to download word document stored in database as content data in sql server??

How to download a word document which is stored in database, sql server as a content data through C#? This is my Code I'm using: string doctype = dtResumeInfo.Rows[0]["ContentType"].ToString(); string docname = dtResumeInfo.Rows[0]["FileName"].ToString(); // try { Respons...

Query on Sql Joins

I have three tables. tblLink: (LinkId, LinkName, GroupId, ,SubGroupId) GroupId and SubGroupId are foreign key in tblGroup and tblSubGroup tblGroup: (GroupId, GroupName) tblSubGroup: (SubGroupId, SubGroupName) in tblLink SubGroupId is allowed Null but GroupId is Mandatory. I want to fetch LinkName, GroupName, SubGro...

Connect to SQL Server with JS

I stumbled across a post on here regarding connecting to a DB with JavaScript. http://stackoverflow.com/questions/857670/how-to-connect-to-sql-server-database-from-javascript I'm building a gadget for windows vista/7 that will work with My Movies, a movie management app for Media Centre. The My Movies app uses SQL Server 2005 Express f...

How to analayze/display a raw web analytics data?

I've created a web tracking system that simply insert an event information (click or page view) into a simple SQL server table: Column | Type | NULL? ------------------------------------- RequestId | bigint | NOT NULL PagePath | varchar(50) | NOT NULL EventName | varchar(50) | NULL Label | varchar(50) | NULL Val...