sql-server

TSQL increment a colum and start over based on another column

I have a table as follows: colA colB(unique) colC --------------------------------- 1 1449 0.50000000 1 1451 1.03400000 1 2404 5.98750000 1 1454 6.00000000 3 1465 1.40000000 3 1467 1.56000000 3 1476 3.00000000 3 1469 ...

If Facebook or Google had written via Microsoft Technologies, what would have happened.

I wonder, If Facebook or Google had written via Microsoft Technologies, what would have happened. Pros and cons? ...

Disabling foreign key constraint, still can't truncate table? (SQL Server 2005)

I have a table called PX_Child that has a foreign key on PX_Parent. I'd like to temporarily disable this FK constraint so that I can truncate PX_Parent. I'm not sure how this goes however. I've tried these commands ALTER TABLE PX_Child NOCHECK CONSTRAINT ALL ALTER TABLE PX_Parent NOCHECK CONSTRAINT ALL (truncate commands) ALTER ...

SQL Server full-text search

I want to use the full-text index to search word: How can I use 'contain' or 'freetext' to get the same result as "like '%dd%' "? If I use contain(table,'data'), it only finds "....the data is ...." How can I use contain search 'dat' to find data? ...

Updating table with new objects without mass delete through LINQ to SQL in C#

I am new to database programming and want some tips on performance / best practices. I am parsing some websites to scrap television episode infos and placing them into an MS SQL 2008 R2 relational database. Lets say i have a table filled with type Episode. When i start a new parsing, i generate a new list of Episodes. The thing is, ...

SQL Server: Do I need to use GO statements between batches?

I have seen people use GO statement between batches of SQL code, but AFAICS it is not mandatory (SQL Server 2008). What are the benefits using GO statements between batches/sets of SQL statements? ...

"system objects" vs. "server objects" in SQL Server - terms definitions?

What are the definitions of "system object" and of "server object" in SQL Server? Is Server object also system one? And vice versa? And what are the differences between "system" and "server' objects in SQL Server? What's distinguishing them? Update: There is a node in Object Explorer of SSMS for Server Objects (I have now on...

can i use self join on table for insert new data

if yes please give me just a example thankzzz ...

storage location of server objects in SQL Server

Subquestioning [1] and [2]. Where does SQL Server store server objects? And why there? Update: This question is defined as subquestion and in context of cited questions... Should I understand the answer that sql_policy_trigger, shown under Server Objects\Triggers in Object Explorer of SSMS (MS SQL Server R2), is stored in mast...

Substring in sql...

I have a column in SQL table which would have data like this: "College: Queenstown College" or "University: University of Queensland" Text before the ":" could be different. So, how can i select only the text before the ":" from the column and text after the ":(space)"? ...

Why are system views duplicated to user databases?

Why has SQL Server to duplicate a hundred of system views from model database into each user-defined database instead of keeping them centralised (for example, as it keeps server objects) and using them in specific context of specific database when asked/needed? Aren't they (for example, definitions/script of a system view) common b...

Insert data in to sql server data table

Hi , I have one table customer_master and column cust_id is autoincrement 1 .when we are try to insert its working fine and inserted records like cust_id 1 and 2,3,4 but when generate error in insert command we do transaction rollback means cust_id 5 is not insert but when we are insert another record cust_id generate 6 . skip cust_id...

Another substring question in sql server

Below are the data in a column of my database: "ABC;123; TGH" "DEF;123456; TFG" How can i get the text "123" and "1234546" from both the data above? ...

Sync Data Between Two Diff SQL Servers

I have two SQL servers that I need to have identical. Sync should occur maybe a couple times per day, automatically. The two servers have no "direct" connection between them, so no linked db etc. (They are on totally diff machines, networks, domains, with firewalls between etc) You can use the Internet though, like Web Service, FTP... ...

Error in my trigger

Hello everyone. I am working on a project using SqlSiteMapProvider. I have two tables Articles and SiteMap Articles table: CREATE TABLE [dbuser].[Articles]( [ArticleId] [uniqueidentifier] NOT NULL, [Title] [nvarchar](500) NULL, [Description] [ntext] NULL, [CategoryId] [int] NULL, [pubDate] [datetime] NULL, [Author] [nvarchar](25...

Get new ID before insert during transaction in .NET

I'm using ADO.NET to try to get the value I'm about to insert before I insert it in SQL Server 2005. SCOPE_IDENTITY() works fine after, but I'm also inside a transaction if that makes a difference. I literally need to select the next ID, and only the ID and have it available to C# before the insert. ...

Sql server bulk delete by known record ids

Hi. I need to delete many rows from sql server 2008 database, it must be scalable so i was thinking about bulk delete, the problem is that the are not many references on this, at least in my case. The first factor is that i will exactly know the ID of every row to delete, so any tips with TOP are not an option, also i will delete less ...

CTE concatenation missing first row in group iteration

I am attempting to concatenate multirow values into single row...I have achieved a close proximity but realize that the query below misses the first row every time...am I missing something obvious here? I have never used CTE before so I'm trying hard to understand the concepts behind it. Thanks in advance. WITH CTE ( AnswerResponseRefId...

Help me write a SQL Crosstab query

I have 3 tables that look like this: tblVideo: VideoID | Video Name 1 video 1 2 video 2 3 video 3 4 video 4 tblCategory: CategoryID | CategoryName 1 category1 2 category2 3 ...

select 10 rows with lowest time difference in sql

I'm using sql-server 2005 Hi, i have Users table with userID and registrationDate. I want to select shortest period of time between two registrationDates when first date is x and other row is x+10 rows. I don't mind cursor because i will run this query once in a while. I will explain again, i need shortest period of time between 10 us...