sql-server-2008

How can I view the number of tables existing under one particular Owner?

I need to view the number of tables existing under one particular Owner/Creator. How would I do this? Note: I am using SQL Server 2008. ...

Inserting Parent Child XML Data into SQL Server 2008

Hello, I have a xml document as string. I need to insert the data into Master and Detail tables in SQL Server 2008. I tried OpenXML and I want to use some other way in VB.net. I am using .net 3.5 <Orders> <Product> <productID>1</productID> <productName>Pens</productName> <ProductDetails> <productID>1...

port number of SQL Server

Hello everyone, I am wondering what ports are used by SQL Server database engine? I need such port number to write configuration scripts to grant access to specific port of the machine installed with SQL Server to make it safe. A related question is whether SQL Server database engine will use one static port number to serve all client r...

What is wrong with my stored procedure?

I need to insert the selected data from tblA to tblB only if data selected does not exist in tblB. I created a button that will execute this stored procedure. I cannot figure out what I am doing wrong in my stored procedure, it is not inserting/showing non existing data into tblB. I am using SQL Server 2008 and ASP.NET. CREATE PROCEDU...

Uniqueidentifier PK: Is a SQL Server heap the right choice?

OK. I've read things here and there about SQL Server heaps, but nothing too definitive to really guide me. I am going to try to measure performance, but was hoping for some guidance on what I should be looking into. This is SQL Server 2008 Enterprise. Here are the tables: Jobs JobID (PK, GUID, externally generated) StartDate (datetime...

How do I join this sql query to another table?

I have the following SQL query and so far it works the way it should and gets the top 40 tag ids that I have stored in the tagmap table. SELECT TOP 40 tbrm_TagMap.TagID, Count(*) FROM tbrm_TagMap GROUP BY tbrm_TagMap.TagID ORDER BY COUNT(tbrm_TagMap.TagID) DESC I also want to join to the Tags table which contains the actual name of ea...

Installing Sql Server 2008 on Windows 7 RTM

Has anybody found a way to install Sql Server 2008 on Windows 7 RTM? The Windows 7 installer compatibility wizard indicated that 2008 has incompatibilities and the Sql Server 2008 installer causes the Windows 7 to throw up a warning and then eventually errors out with an "Object reference" error. ...

SQL Server Varbinary(max): select a subset of bytes from the varbinary field

What is the most efficient way of reading just part of the binary data from a varbinary(MAX) field (not using FileStreams) in SQL Server 2008? When writing data to the column the VarBinary.Write() function is available in T-SQL, allowing bytes to be written to the field incrementally, but there doesn't appear to be a similar function a...

What SQL Server 2008 Edition can I fly with?

Hello, I have designed an ecommerce software suite that I am going to be hosting for multiple sites (20-50) on a single Virtual Dedicated Server. (64-Bit, machine that has 960 MB of RAM) Each site has its own database. I plan to install SQL Server 2008 however I am not sure which version is best. I would like to start with the free expr...

CASE in ORDER BY few columns

Using a case-then block, I need to choose how to order my SQL 2008 query, by [status] ASC, [date] DESC or just [date] DESC. I know only how to use one column: SELECT * FROM table ORDER BY CASE WHEN @flag = 0 THEN R.[date] END DESC, CASE WHEN @flag = 1 THEN R.[status] END ASC How to use both columns in second CASE? ...

Cleaning up a database

I have a database with hundreds of tables. I am building a script to delete all of the rows in this database. Of course, being a relational database, I have to delete rows from the children before I can touch the parents. Is there something I can use for this or do I have to do this the hard way? EDIT Accepted Answer was modified t...

Can i say that one column is more important then another in a full-text search?

I use Full-text indexing in SQL Server 2008. I can't seem to find an answer to this question. Say that i have a full-text index on a table with the columns "Name" and "Description". I want to make the "Name" column much more important then the "Description" column. So if you search for "Internet" the result with the name "Internet" wil...

How to make SQL Server 2008 Check Constraint of a table Allow Only Certain characters?

I'd like to create a check constraint for a table in SQL 2008 which would allow A-Z characters (non case sensitive), numbers, hyphen (-), dot(.), space and underscore (_). Below is my current expression: ([company_code] not like '%[^A-Za-z0-9_ .+]%'). It fulfills all the above requirements except for hyphen. How could I make the express...

What is the max number of parameters that can be passed in stored procedure

Server in qustion is SQL Server 2008. On the same note, I need to know what is the max length of the string parameter passed in SP? ...

Cost of Inline Table Valued function in SQL Server

Is there an inherent cost to using inline-table-valued functions in SQL Server 2008 that is not incurred if the SQL is inlined directly? Our application makes very heavy use of inline-table-valued functions to reuse common queries, but recently, we've found that queries run much faster if we don't use them. Consider this: CREATE FUNC...

How do I make schema changes to a mirrored database?

I have a mirrored database and I need to make some changes to it. Mainly, adding a view and some stored procedures. Now I know that if you make schema changes you are supposed to remove mirroring and the mirror database, make your changes to the principal, then backup-restore the principal and restore mirroring. Is this the case for s...

Subfolders under Queries in SQL Server 2008 Solution

Can you add subfolders under Queries in SQL Server 2008 Solution? There are large number of query files and it is getting unmanageable. ...

Is it possible to pause an SQL query?

I've got a really long running SQL query (data import, etc). It's crap - it uses cursors and it running slowly. It's doing it, so I'm not too worried about performance. Anyways, can I pause it for a while (instead of canceling the query)? It chews up a a bit of CPU so i was hoping to pause it, do some other stuff ... then resume it. I...

How to set value of parameter to be in MB or in KB (in MS SQL 2008)?

It works well if I write the query like this: ALTER DATABASE [test] MODIFY FILE ( NAME = N'test_log', SIZE = 3456KB, MAXSIZE = 6789999KB, FILEGROWTH = 2345KB) But it is a problem, if I try to use parameters: ALTER DATABASE [@DbName] MODIFY FILE ( NAME = N'@LogFileName', SIZE = @InitialSize, MAXSIZE = @MaxSize , FILEGROWTH ...

ORDER BY in a Sql Server 2008 view

Hi all... we have a view in our database which has an ORDER BY in it. Now, I realize views generally don't order, because different people may use it for different things, and want it differently ordered. This view however is used for a VERY SPECIFIC use-case which demands a certain order. (It is team standings for a soccer league.) Th...