sql-server

Alternative TSQL

Hi there This query works well as you can see I have to put split between between @SearchCriteria and the rest of the query due to it's varchar. If I forced, the syntax works well BUT it return nothing when you query possible because extra ' Can you help? ALTER PROCEDURE [dbo].[sp_rte_GetRateList] ( @TenantID INT, @Cu...

Can I pass the result of a select statement as a value for a parameter into a stored procedure?

I was just trying this knowing that my select would return one row. Is something like this possible or will I need a temporary variable? lets say my stored procedure took one parameter: exec dbo.GetUserData @UserName = UserName from @MyTempTable where UserId= @UserId Or what if the parameter expected was XML? Is there a way I can do ...

SQL authentication in SQL Server 2008

I have this problem. I first connect(log) to SQL Server using SQL Management Studio the authentication is set to Windows Authentication. Then I go to the Security => Logins folder and add a user, the authentication is: SQL Server authentication, I give him also the sysadmin role [all roles] I try to login as that user, but I can't I...

Changing column constraint null/not null = rowguid replication error

I have a database running under Sql server 2005 with merge replication. I want to change some of the FK columns to be 'not null' as they should always have a value. SQL server won't let me do that though, this is what it says: Unable to modify table. It is invalid to drop the default constraint on the rowguid column that is us...

java:not able to set auto commit mode with value false in java 1.4 api?

sql server 200 java 1.4 jboss 3 HI am getting exception message "You cannot set autocommit during a managed transaction" code is below try { try { connection = getConnection(); } catch (Exception e) { throw new ConnectionException(e.getMessage()); } for(int i=0;i<recordIds.size();i++) { String cu...

TSQL: How do I get the size of the transaction log?

How do I get the current size of the transaction log? How do I get the size limit? I'd like to monitor this so I can determine how often I need to backup the transaction log. I usually have a problem with the transaction log when I perform large operations. ...

How to hide the date and id from the table

Using SQL Server 2005 I want to hide the date from table1 where table1.id = table2.id and table1.date = table2.date Table1 ID Date 001 01-01-2009 001 02-02-2009 001 03-01-2009 001 04-01-2009 002 01-01-2009 002 02-02-2009 002 03-01-2009 ..., Table2 ID Date Holiday 001 01-02-2009 0 001 02-02-2009 1 001 03-01-2009 0 001 04-01-2009 ...

Is there an easy method of process mapping a complex SSIS package so I can print it out?

I have taken ownership of a very complex SSIS package with multiple files and routes. Is there an easy method of process mapping the whole process automagically so I can print it out and understand it? Edit: Added a screenshot of an example SSIS package that I need to map. Cheers, Ian. ...

MySQL vs. SQL Server vs. Oracle...

Hi Guys, I have always only used MySQL and no other database system. A question came up at a company meeting today and I was embarrassed I did not know: To a developer, what earth-shaking functionality do MS or Oracle offer that MySQL lacks and which allows MS and Oracle to charge for their systems? ...

Is Microsoft going to support SQL Server 2008 with LINQ in Visual Studio 2010?

Hello everyone, Is Microsoft going to support the features of SQL Server 2008 such as Hierarchyid and Filestream with LINQ in Visual Studio 2010 at last? Thanks P.S: Tired of having features in SQL Server that Microsoft's own tools don't support. Please let me know if it's worth the upgrade. ...

How to copy views from one database to another database

I have two databases with same structure in MS SQL server. I'd like to copy all views another database. I tried to use Export data functionality by DTS (that works with the table objects). But that executes the SQL & creates the table object. I don't want to execute that just want to copy the view so that I can open them in design vi...

How can I make MySQL's LIMIT in SQL Server?

I'm retrieving thousands data from database. I would like to show on web pages by limit of 100 records. I can show First 100 record with the following SQL: SELECT TOP 100 * FROM TBLStock And How can I navigate next records 101 to 200, 201 to 300, etc.. ? Please Help me. I am using SQL Server 2005. HELP! How can I write in SQL Server l...

SQL Server Foreign Key Problem

Hi, I am trying to create a foreign key constraint consisting of an int column and a datetime column (both not null). I am getting the error "There are no primary or candidate keys in the referenced table X that match the referencing column list in the foreign key FK". Normally this error means that the column(s) in the target table i...

How we can use CTE in subquery in sql server?

How we can use CTE in subquery in sql server? like .. select id (i want to use CTE here), name from table_name ...

SQL Syntax to Pivot multiple tables

Hi, I have spent the past couple of days working on this and am going around in circles. My question is based around the answer I accepted in this post: stackoverflow question I now have my data moved from a single 400 column table to a much more managable database structure with many thanks to Damir Sudarevic. My database looks li...

Some questions about HierarchyId (SQL Server 2008)

I am a newbie in SQL Server 2008 and just got introduced to HierarchyId's. I am learning from SQL Server 2008 - HIERARCHYID - PART I. So basically I am following the article line by line and while practicing in SSMS I found that for every ChildId some hexadecimal values are generated like 0x,0x58,0x5AC0 etc. My questions are What a...

C# When creating a table I get "incorrect syntax" error if my column / field name contains a "-" hyphen.

Hi all, Below is a snippet of my code, when a table name contains a hyphen, I get the error below. How can I fix this? Thanks for the help. ex = {"ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '-'."} ...

Randomized Linq2SQl query that's return too heavy SQL

I use the following to implement Random ordered results in Linq2SQL: partial class OffertaDataContext { [Function(Name = "NEWID", IsComposable = true)] public Guid Random() { throw new NotImplementedException(); } } In the following query: IEnumerable<Enquirys> visibleOnSite = En...

SQL Server 2008: Can a multi-statement UDF return a UDT?

Is it possible that a multi-statement UDF return a User Defined Table Type, instead of a table that is defined within it's return param? So instead of: CREATE FUNCTION MyFunc ( @p1 int, @p2 char ) RETURNS @SomeVar TABLE ( c1 int ) AS I would like to do: CREATE FUNCTION MyFunc ( @p1 int, @p2 char ) RETURNS @SomeVar M...

How does one create a new Entity Framework Model by referencing an existing model?

We would like to publish a base model, that represents our core business data. Separate departments would reference this base model, (published as an .NET assembly) Their project would create their schemas that reference the core business schema. Is it possible that each team would reference this common assembly, and then build their o...