We have two SQL server database, and one is kept in US and being changed from day to day and the other one is in India. What is the best way of keeping two database schema in synch. Does any functionality like sql server replication help?
...
I have a table with two columns, customer id and order.
Let's say I have in total order IDs 1,2,3,4
All the customer can have all the four orders, like below:
1234 1
1234 2
1234 3
1234 4
3245 3
3245 4
5436 2
5436 4
You can see above that 3245 customer doesn't have order id 1 or 2.
How could I print in ...
I wrote a T-SQL query which includes a test for valid EmployeeNo. If the EmployeeNo is not valid, I do the following:
RAISERROR(5005, 10, 1, N'Invalid Employee No')
return @@Error
Back in VB.Net I test the sql exception and found that when the Employee No is invalid the error.number is not 5005 as I would expect, but 2732.
What is th...
Hello,
I'm building an Event Registration site. For any given event, we'll have a handful of items to choose from. I have a table for these items. For each event we might have special options for users. For example, for one of the events new users get to buy an item which is not available to other users. This may not apply to all t...
declare @t1 Table
(
a1 int
)
insert into @t1
select top 10 AnimalID from Animal
--select * from @t1
declare @t2 table
(
dogs int null
)
update @t2
set dogs = (Select COUNT(*) from @t1)
---------> The out put it gives me is just 0
...
Hi, I'm here again-
I have something like this
Select A.a, A.b, A.a+A.b as c, (A.a+A.b*2)+A.d as d from Table
But i want to know, if it is possible, to make it work with something like this:
Select A.a,A.b,A.a+A.b as c, (c*2)+A.d as d from Table
Thank you
...
SQL Server Full-Text Search computes rank based on the frequency of the word in the document and in the set of all documents (TFIDF). Is it possible to access these values directly ?
I would like to find the top-n most frequent words in my table. Is it possible to obtain this list from the full-text search index?
I'm using SQL Server ...
I've got a stored procedure with a select statement, like this:
SELECT author_ID,
author_name,
author_bio
FROM Authors
WHERE author_ID in (SELECT author_ID from Books)
This limits results to authors who have book records. This is the Books table:
Books:
book_ID INT,
author_ID INT,
book_title NVARCHAR,
featured_book B...
Based on an existing table I used CTE recursive query to come up with following data. But failing to apply it a level further.
Data is as below
id name parentid
--------------------------
1 project 0
2 structure 1
3 path_1 2
4 path_2 2
5 path_3 2
6 path_4 3
7 path_5 4
8 path_6 ...
I have a database with the following tables:
Employee (EmpID, FirstName, LastName, RegionID)
EmployeeSkills(EmpID, SkillID) [this is a linking table for the M:N relationship between Employees and skills]
Skills(SkillID, Description)
I need to list the name of the skill that most employees have. I tried doing a max(count(skillID)), sql...
I'm working on a legacy VB6 app here at work, and it has been a long time since I've looked at VB6 or ADO. One thing the app does is to executes SQL Tasks and then to output the success/failure into an XML file. If there is an error it inserts the text the task node.
What I have been asked to do is try and do the same with the other m...
I have a few tables where Foreign Key constraints are added. These are used with code generation to set up specific joins in generated stored procedures.
Is it possible to override these constraints by calling multiple deletes within a transaction, specifically "TransactionScope" in C# or is cascaded deleting absolutely required?
...
Hi guys! Im sure this will be pretty simple for a t-sql guru.
I have the following result from a table
idMain IdSecondary TextValue
1 1 text1
1 2 text2
2 5 text3
2 6 text5
And I want to obtain the first occurence of the idMain only.
The result should be like this....
a) Quote is taken from http://www.postgresql.org/docs/current/static/tutorial-window.html
for each row, there is a set of rows within its partition called its window frame. Many (but not all) window functions act only on the rows of the window frame, rather than of the whole partition. By default, if ORDER BY is supplied then the fra...
Are there any constants in T-SQL like there are in some other languages that provide the max and min values ranges of data types such as int?
I have a code table where each row has an upper and lower range column, and I need an entry that represents a range where the upper range is the maximum value an int can hold(sort of like a hackis...
I am making an URL shortener, and I am struggling with the optimal way of encoding a number (id) into a character string.
I am using the characters 0-9,A-Z,a-z so it will basically be a base-62 encoding. That is pretty basic, but it doesn't make use of all possible codes. The codes that it would produce would be:
0, 1, ... y, z, 10, 11...
I know MS T-SQL does not support regular expression, but I need similar functionality. Here's what I'm trying to do:
I have a varchar table field which stores a breadcrumb, like this:
/ID1:Category1/ID2:Category2/ID3:Category3/
Each Category name is preceded by its Category ID, separated by a colon. I'd like to select and display t...
Could some one please help me understand when to use SNAPSHOT isolation level over READ COMMITTED SNAPSHOT in SQL Server?
I understand that in most cases READ COMMITTED SNAPSHOT works, but not sure when go for SNAPSHOT isolation.
Thanks
...
I'm experiencing a weird problem with a SQL login. When I connect to the server in Microsoft SQL Server Management Studio (2008) using this account, I cannot see any of the tables, stored procedures etc. that this account should have access to on a particular database.
When I connect to the same server within Visual Studio (2008) with t...
We have a scalar function that returns a DateTime. It performs a couple of quick table selects to get its return value. This function is already in use throughout the database - in default constraints, stored procs, etc. I would like to change the implementation of the function (to remove the table hits and make it more efficient) but ap...