sql-server

Table/column names enclosed in square brackets, even though their names consist of legal characters

Square brackets allow you to use names for columns or aliases that contain characters not permitted for column names or aliases. a) I’ve noticed that lots of times table and column names are enclosed inside square brackets, even though their names consist of perfectly legal characters. Why is that? b) As far as I know, square brackets...

FULL TEXT Search – usefulness of Ranking

RANK column indicates how well a row matched the selection criteria. SELECT * FROM CONTAINSTABLE ( someTable, *, 'surf OR life' ) AS ct INNER JOIN someTable ON ct.[KEY] = someTable.i Assuming we run the above query, I would expect that the two rows returned by a query ( one containing string life and other containing stri...

How to create a column that can never be updated?

In SQL Server 2008, is it possible to create a column that can have a value inserted into it, but can never be updated? In other words, the column can have an initial value inserted into it, but once it contains a non-null value, it can never be changed. If possible, I would prefer to do it without using a trigger. Thanks - Randy ...

primary key datatype in sql server database

i see after installing the asp.net membership tables, they use the data type "uniqueidentifier" for all of the primary key fields. I have been using "int" data type and doing increment by one on inserts and declaring the column as IDENTITY. Is there any particular benefits to using the uniqueIdentifier data type compared to my current ...

how do I integrate the aspnet_users table (asp.net membership) into my existing database

i have a database that already has a users table COLUMNS: userID - int loginName - string First - string Last - string i just installed the asp.net membership table. Right now all of my tables are joined into my users table foreign keyed into the "userId" field How do i integrate asp.net_users table into my schema? here are the i...

What port is my SQL2008 instance running on?

Check out this pic of my SQL 2008 Management Configuration screen for TCP: I need to know what port I am running on. Based on this previous post, I don't believe that it is 1433, which I guess is the default. When I check my port number in SQL Config Mgr., it is blank. Does this suggest a default port? Note that I have multiple SQL ...

suitable data type to save string larger than 8000 charachter

what is the suitable data type to save string more than 8000 character in SQL database? ...

Access DB with SQL Server Back End

I have an old Access application that has a lot of code in forms and reports. The database is getting too large and I am thinking of moving the back end to SQL Server. My requirements are as follows: The DB needs to be multiuser and the users (3-5) will need to log in over the web I would prefer not to re-write the forms and report...

How to Select Multiple Records from Multiple Tables at Once

I have two tables Customer and CustomerPhone. Customer usually has multiple phone numbers, so when i run select statement on customer 101, i will get multiple records due to the multiple phone numbers. As you see below all the "Phone" and "Fax" field belongs to CustomerPhone table. These are considered as two records in the CustomerPh...

Synchronizing two SQL Server databases using MS Sync Framework

I have one central SQL Server database which can be offline from time to time. I have a desktop application using Local DB Cache (SQL CE) to synchronize with the central database and I also have a web application with its own SQL Server that I'd also would like to keep synchronized. All synchronizations must be bidirectional. Is there a...

move data in bulk from oracle to SQL database

Hi All... Would like to know which is the best way to move data in bulk from oracle to SQL database programmatically in VB.NET application.This application is suppose to run continuously and moves data from Oracle to SQL whenever data comes. I have found OPENDATASOURCE but does not know the exact syntax. Can someone help me out. Than...

What's SQL table name for table between 'Users' and 'UserTypes' ?

i have two tables in my database : Users : contain user information UserTypes : contain the names of user types ( student , teacher , specialist ) - I can't rename it to 'Types' as we have a table with this name relation between Users and UserTypes many to many .. so i'll create a table that have UserID(FK) with UserTypeID(FK) but I...

SQL Server - What's in that log backup?

So I noticed that one of my log backups is about 1000x larger than normal. I'd like to see what is in there. Is there something I can use to read it? Thanks! ...

xml serialization and for xml sql server

Hello, I've a SQL statement that returns a xml result, for a serialized object.I want to add a attribute to an element, that reflects the type of the object "xsi:type=table" but i don't know how? ...

Convert date to ticks in SQL Server

Does anyone know how to convert a DATETIME COLUMN to TICKS in SQL Server? ...

Making flexible C# code in MVC2 for Stored Procedures

Thanks to Darin Dimitrov's suggestion I got a big step further in understanding good MVC code, but I'm having some problems making it flexible. I implemented Darin's suggested solution, and it works perfectly for single controllers. However I'm having some trouble implementing it with some flexibility. What I'm looking for is this; To...

Unexpected behaviour of Order by clause

I have a table which looks like Col1 col2 col3 col4 col5 1 5 1 4 6 1 4 0 3 7 0 1 5 6 3 1 8 2 1 5 4 3 2 1 4 The script is declare @t table(col1 int, col2 int, col3 int,col4 int,col5 int) insert into @t select 1,5,1,4,6 union all select 1,4,0,3,7 union a...

Creating a CLR UDF with variable number of parameters

Hi I wanted a function to find the greatest of a list of String values passed in. I want to invoke it as Select greatest('Abcd','Efgh','Zxy','EAD') from sql server. It should return Zxy. The number of parameters is variable.Incidentally it is very similar to oracle GREATEST function. So I wrote a very simple CLR function (Vs2008) and t...

multi-part identifier could not be bound error

Here is my query: IF OBJECT_ID('NPWAS1513.dbo.usp_MSPEX_QLK_Billing_Fact_Load') IS NOT NULL DROP PROCEDURE dbo.usp_MSPEX_QLK_Billing_Fact_Load; GO CREATE PROCEDURE usp_MSPEX_QLK_Billing_Fact_Load @create_timestamp datetime, @update_timestamp datetime, @create_user varchar(50), @update_user varchar(50), @dbProdServ varchar(...

can we have a foreign key which is not a primary key in any other table?

it is written in every book that foreign keys are actually primary key in some other table but can we have a foreign key which is not primary key in any other table ...