sql-server

Can't bulk insert file

I have a 5GB file that I need to bulk insert into a SQL Server database (2005 SP2). When I attempt to do so (using a format file that worked in the past for the same import file), I get the error: The transaction log for database 'tempdb' is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in ...

SQL Database design help needed

I am trying to limit the about of tables in my database because I hear that's good (I am a novice web developer). I want to have the user input a list into the database. So they input a title, overall comment, and then start making the list. I can't figure out how to do this without making a new table for each list. Because, say one user...

Integer zero, "0' will be ignored when upload to SQL Server.

i have a page that allow user to upload an excel file and insert the data in excel file to the SQL Server. Now i have a small issue that, there is a column in excel file with values, such as "001", "029", "236". When it's insert to the SQL Server, the zero in front will be ignored in SQL, so the data would become "1", "29", "239". The da...

How to create 20 databases at a time in sqlserver?

Hi, I have written the following procedure to create a series of 20 databases. But it is not creating them. The database is not created even when I go to my H: drive and didnot find the ldf and mdf named bharath1 bharath2 like... What did I do wrong with this? USE master GO DECLARE @command varchar(1000), @i int while @i < 5 SET @...

How do I refactor repetitive SQL update queries?

I have 3 tables. 1. Users 4 Cols UserID - User - RealName - Flags 2. UsersGroups 2 Cols UserID - GroupID 3. Groups 3 Cols GroupID - Group - Flags and I want to set the flags on the User table for User = 'Administrator' and apply the same to the Group table. I have the following SQL that works, but I also have several flags that I ...

checkbox data binding

How to add a check box in a .aspx page. I had used a database. and i read data from the database successfully. And now the readed data is in data table "dt". And i added this statement if (dt.Rows[0]["IsActive"].ToString() == "True") if the condition is true, Then the check box will be checked? but i didn't get. How it will get? ...

Performance consideration: Spread rows in multiple tables vs concentrate all rows in one table.

Performance consideration: Spread rows in multiple tables vs concentrate all rows in one table. Hi. I need to log information about about every step that goes on in the application in an SQL DB. There are certain tables, I want the log should be related to: Product - should log when a product has been created changed etc. Order - same ...

SQL Server Transactional Replication - How do I use a stored procedure to synchronise a subscriber

Hi, I have two servers, one in the office and another on a dedicated server that drives our website. The office runs SQL Server 2005 and the dedicated server is 2005 Express. Until now I've automated backing up our office database, FTP'ing it to the dedicated server and restoring it. This has worked fine but it's now taking around 45 ...

SQL GROUP BY: Getting the most recently updated record for an indexed view

I'm trying to do row versioning using an indexed view, grouping records by their key and timestamp, and taking the max(timestamp) record. This is fine, but the query I have used (see the view below) does a self join, meaning it can't be used in an indexed view, which i think will be essential to performance. Is there a way to rewrite the...

Default Value Storage

I have the following three tables: Item Code ItemCode (many to many relationship between Item and Code) And then I have the following sample data on the third table: Item | Code -----+----- 001 | A 002 | A 003 | B There's a possibility that a new Item is added but does not have a code yet. I will assign a default code for this ...

What does LSN mean in SQL Server?

What is the meaning of Log Sequence Number? I know that it is of type binary and 10bytes long and it corresponds to the time the transaction happen in DB. But is this a high precision date-time value that is stored in some efficient binary format or is this a function of date-time and something else (for example the serial number of tran...

Business Objects XI performing DISTRIBUTED TRANSACTION by default-How to turn off?

I have a Business Objects Web Intelligence report that is performing a distributed query against two databases. When I run this query that includes a BEGIN DISTRIBUTED TRANSACTION QUERY SET xact_abort ON GO USE Pipeline2 GO BEGIN DISTRIBUTED TRANSACTION SELECT * FROM [CQSR_PROD].CqUSer.Cq4User1.Defect COMMIT TRAN GO I get this erro...

How scope of variable defined/flows in SQL statements compared to LINQ

Here in this video at 11th minute, while explaining about strange structure (compared to SQL) of LINQ query, Anders Hejlsberg says that "Scope of variables in SQL flows backward in SQL", What does he mean by that? I'm totally confused... :( ...

What is the internal representation of datetime in sql server?

What is the underlying datastructure of datetime values stored in SQL Server (2000 and 2005 if different)? Ie down to the byte representation? Presumably the default representation you get when you select a datetime column is a culture specific value / subject to change. That is, some underlying structure that we don't see is getting ...

Why would SqlServer select statement select rows which match and rows which match and have trailing spaces

I have a table created with: SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[TestFeature1]( [Id] [nvarchar](50) NOT NULL, [Leng] [decimal](18, 0) NOT NULL ) ON [PRIMARY] GO SET ANSI_PADDING OFF I inserted data with this: insert into TestFeature1 (id,leng) values ('1',100); insert into Test...

What is the difference between drop table and delete table in SQL Server?

Hi In SQL Server, what is the difference between the following two- Right click on a database object (table/view) and opt for Drop table (i.e. Script table as -> DROP To -> New Query Editor Window) Right click on a database object (table/view) and opt for Delete. I tried them both and both perform the same action. Any reason for hav...

How to handle multiple wildcards with SQL Server

Hello, I have some filters in the following form: Object A +/- Start End ---------------------------------------------- + 000000080000 000000090000 - 000000800500 + 054* Object B +/- Start End ---------------------------------------------- + 000000090000 000000100000 + 00??00900500 - 000000900500 + ...

Selecting data from two different servers in SQL Server

How can I select data in the same query from two different databases that are on two different servers in SQL Server? ...

How to design this database?

I have to design a database to store log data but I don't have experience before. My table contains about 19 columns (about 500 bytes each row) and daily grows up to 30.000 new rows. My app must be able to query effectively again this table. I'm using SQL Server 2005. How can I design this database? EDIT: data I want to store contain...

SQL Server Check Constraint Inquiry

I have a table which stores payments and want to ensure if the payment method is a credit card then the card type field should be IN ('Visa', 'MasterCard', 'Discover', 'American Express'), however if the payment method is not a credit card then the card type field should be NULL. Will a check constraint allow me to use a statement like ...