tagged [sql]

how can I Update top 100 records in sql server

how can I Update top 100 records in sql server I want to update the top 100 records in SQL Server. I have a table `T1` with fields `F1` and `F2`. `T1` has 200 records. I want to update the `F1` field ...

8 Mar at 06:53

Sql server Integration Services 2008-2005 compatibility

Sql server Integration Services 2008-2005 compatibility I recently developed an SSIS package on my dev machine using the 2008 version. Later I foud the customer had Sql server 2005 and doesn't plan to...

Is there a way to list open transactions on SQL Server 2000 database?

Is there a way to list open transactions on SQL Server 2000 database? Does anyone know of any way to list open transactions on SQL Server 2000 database? I am aware that I can query the view `sys.dm_tr...

Is the LIKE operator case-sensitive with SQL Server?

Is the LIKE operator case-sensitive with SQL Server? In the [documentation about the LIKE operator](http://msdn.microsoft.com/en-us/library/ms179859.aspx), nothing is told about the case-sensitivity o...

21 Dec at 00:13

Error on renaming database in SQL Server 2008 R2

Error on renaming database in SQL Server 2008 R2 I am using this query to rename the database: But it shows an error when excuting: > Msg 5030, Level 16, State 2, Line 1 The database could not be exc...

22 May at 08:9

Reset identity seed after deleting records in SQL Server

Reset identity seed after deleting records in SQL Server I have inserted records into a SQL Server database table. The table had a primary key defined and the auto increment identity seed is set to “Y...

Safest way to get last record ID from a table

Safest way to get last record ID from a table In SQL Server 2008 and higher what is the best/safest/most correct way 1. to retrieve the ID (based on autoincrementing primary key) out of the database t...

6 Aug at 08:37

SQL update query using joins

SQL update query using joins I have to update a field with a value which is returned by a join of 3 tables. Example: ``` select im.itemid ,im.sku as iSku ,gm.SKU as GSKU ,mm.ManufacturerId as ...

How to update Identity Column in SQL Server?

How to update Identity Column in SQL Server? I have SQL Server database and I want to change the identity column because it started with a big number `10010` and it's related with another table, now I...

14 May at 07:13

How to kill/stop a long SQL query immediately?

How to kill/stop a long SQL query immediately? I am using SQL server 2008 and its management studio. I executed a query that yields many rows. I tried to cancel it via the red cancel button, but it ha...

10 Apr at 09:3

SQL Server - Return value after INSERT

SQL Server - Return value after INSERT I'm trying to get a the key-value back after an INSERT-statement. Example: I've got a table with the attributes name and id. id is a generated value. Now I want ...

27 Oct at 14:46

Add primary key to existing table

Add primary key to existing table I have an existing table called `Persion`. In this table I have 5 columns: - - - - - When I created this table, I set `PersionId` and `Pname` as the . I now want to i...

SQL, How to Concatenate results?

SQL, How to Concatenate results? I currently have a SQL query that returns a number of fields. I need one f the fields to be effectively a sub query sub that. > If I have a table X with two columns, M...

Get last 30 day records from today date in SQL Server

Get last 30 day records from today date in SQL Server I have small question about SQL Server: how to get last 30 days information from this table Sample data: `Product`: Based on this table data i wan...

Can I create a One-Time-Use Function in a Script or Stored Procedure?

Can I create a One-Time-Use Function in a Script or Stored Procedure? In SQL Server 2005, is there a concept of a one-time-use, or local function declared inside of a SQL script or Stored Procedure? I...

Convert SQL Server result set into string

Convert SQL Server result set into string I am getting the result in SQL Server as I am getting the output like The output parameter of the stored procedure is `@studentId` string and I want the retur...

27 Jan at 17:7

T-SQL datetime rounded to nearest minute and nearest hours with using functions

T-SQL datetime rounded to nearest minute and nearest hours with using functions In SQL server 2008, I would like to get datetime column rounded to nearest hour and nearest minute preferably with exist...

SQL DELETE with INNER JOIN

SQL DELETE with INNER JOIN There are 2 tables, `spawnlist` and `npc`, and I need to delete data from `spawnlsit`. `npc_templateid = n.idTemplate` is the only thing that "connect" the tables. I have tr...

SQL Server - Create a copy of a database table and place it in the same database?

SQL Server - Create a copy of a database table and place it in the same database? I have a table ABC in a database DB. I want to create copies of ABC with names ABC_1, ABC_2, ABC_3 in the same DB. How...

What does SQL Select symbol || mean?

What does SQL Select symbol || mean? What does `||` do in SQL?

14 Oct at 14:5

What represents a double in sql server?

What represents a double in sql server? I have a couple of properties in `C#` which are `double` and I want to store these in a table in SQL Server, but noticed there is no `double` type, so what is b...

How to delete the top 1000 rows from a table using Sql Server 2008?

How to delete the top 1000 rows from a table using Sql Server 2008? I have a table in SQL Server. I would like to delete the top 1000 rows from it. However, I tried this, but I instead of just deletin...

19 Aug at 19:29

Fastest way to update 120 Million records

Fastest way to update 120 Million records I need to initialize a new field with the value -1 in a 120 Million record table. I let it run for 5 hours before canceling it. I tried running it with transa...

31 Jan at 10:47

Copy data into another table

Copy data into another table How to copy/append data from one table into another table with same schema in SQL Server? let's say there is a query which creates `table1` with the same schema as well as...

21 Apr at 12:25

nvarchar(max) vs NText

nvarchar(max) vs NText What are the advantages and disadvantages of using the `nvarchar(max)` vs. `NText` data types in SQL Server? I don't need backward compatibility, so it is fine that `nvarchar(ma...