sql-server

Migrating DB: Keep relations constraints?

At the risk of being called a fool, I am wondering what your thoughts are on maintaining relationship constraints within a MS SQL DB. I am migrating a system into a .NET environment from ASP. This brings with it business objects and other tiered-coding techniques, which work to abstract the database from the user/API. The new applicatio...

sql server :convert rows to columns

ihave at table with columns sales(int),month (int) . i want to retrieve sum of sales corresponding to every month .i need ouput in form of 12 columns corresponding to each month.in which there will be single record containing sales for for each column(month) ...

Problem inserting data into a varchar field using a stored procedure

I am uploading some data from DB2 to SQL2005. The table contains one text field that is 2000 characters long in DB2 but is set up as a varchar(2000) in SQL. When I run my insert in query browser it processes fine and the data is copied correctly, however when the same statement runs in my stored procedure the data for this field only i...

What does "%%DatabaseEx" do in TSQL?

I was looking at the source of sys.sp_dbcmptlevel in SQL Server 2005. In the source, there is this line I do not understand how it works. EXEC %%DatabaseEx(Name = @dbname).SetCompatibility(Level = @input_cmptlevel) It doesn't appear that DatabaseEx is a stored procedure. -- does not return any result select * from sys.procedures whe...

How can I have Sql Server 2005 asynchronously call a DOS batch file from a DDL trigger?

I created a batch file to run SqlMetal and generate Linq2Sql data classes, check into source control triggering a build, etc... I'd like to have this script run anytime there is a DDL change in Sql Server 2005. Running the batch file via xp_cmdshell works fine outside of a trigger, like this: exec master..xp_cmdshell 'd:\dev\db_trigge...

SqlCeResultSet and SQL injection

When using this code to insert a row with SqlCeResultSet, SqlCeResultSet resultSet = DataAccess.OpenResultSet("MyTable"); SqlCeUpdatableRecord record = resultSet.CreateRecord(); record.SetString(1,TextBox1.Text); resultSet.Insert(record); Does it prevent SQL injection attacks? ...

TSQL equivalent of an MS Access Crosstab query

What's the equivalent of an MS-Access crosstab query in TSQL? And Is there a better way? I have a data organised like this: Fish ID Name ---- --------- 1 Jack 2 Trout 3 Bass 4 Cat FishProperty ID FishID Property Value ---- ------ -------- ----- 1 1 Length 10 2 1 Girth 6 3 1 Weight 4 4 ...

Temporary table issue in Reporting Services 2000

Hi, I have just created a report in Report Manager using a Stored Procedure which uses a temporary table. I'm getting the error "Could not generate a list of fields for the query. Invalid object name '#xxxx'" I read this is because when Report Manager tries to PrepareQuery it runs into difficulty because the temporary table doesn't ex...

NHibernate joined-subclass

Hello, I'm trying to implement class inheritance hieararchy with NHibernate and SQL server. I made it work fine with the table per hierarchy strategy (one table and several subclass elements in the mapping file). However the table per subclass strategy (N + 1 tables and N joined-subclass elements in one mapping file) makes more sense i...

Can i schedule a job in SQL Server 2000 MSDE?

We are currently evaluation our hosting options and the cheapest suitable option we've found only has SQL Server 2000 MSDE as the db server. Does this have the ability to schedule jobs using SQL Agent? If not, can I use a windows scheduled job to run scripts for me? ...

Does SQL Server 2000 MSDE have DTS?

We are currently evaluation our hosting options and the cheapest suitable option we've found only has SQL Server 2000 MSDE as the database server. Does this version have DTS? ...

Connect to remote server in T-SQL (SQL server 2008)

Does anyone have an example of a stored procedure which makes a connection to a remote server? I have been searching the web and have so far discovered that it might can be done using sp_addlinkedserver and sp_addlinkedsrvlogin but I haven't found a good example and I don't understand the documentation that well. UPDATE: None of the t...

Max DB size in SQL Server 2000 MSDE

We are currently evaluation our hosting options and the cheapest suitable option we've found only has SQL Server 2000 MSDE as the db server. What is the max size of a db on the server? Is there a max total size for dbs combined? ...

Lilian Date function in SQL Server 2008

I am working with an AS400 database and SQLServer 2008. I would like a way to convert a date in say, MM-DD-YYYY into lilian format and back in T-SQL. Anyone know of any? Even if I convert the data that I had in the AS400 into SQLServer 2008 I believe I will still need the same function. ...

Memory Usage

Hi Friends, Can somebody please, let me know that what are the most memory consuming reasons in SQL SERVER 2005? Please, let me know. Thanks, ...

Easy way to import/export Sql Server 2005 users/permissions across instances?

Is there an easy way to export and then import users/permissions from one Sql Server 2005 instance to another? ...

Microsoft Sql Management Studio, SQL Server Agent, Build a Insert Bulk with dynamic parameters.

Here is the syntax to start with (classified data omitted) BULK INSERT [dbName].[dbo].[data_200801] FROM '\\servername\wwwroot\path\Files\data_200904.csv' WITH ( FIELDTERMINATOR = ';', ROWTERMINATOR = '\n' ); This works fine as one of the step of the job. Where I hit a wall is that I need the file name...

what are the correct steps to alter a PK column of a table that is a merge replication source in SQL SVR 2005?

I have a table that has an identity column as the Primary Key. None of the data in the table is important at this point so I can delete it all, but I want to change the column from int to bigint and possibly reseed it to bigint.minvalue so as to give the largest possible range before running out of values. I would like to do this without...

How do you replicate database layout changes on production server?

Let's suppose I want to add a new feature to my ASP.NET MVC application running SQL Server 2008 as a data source. In order to implement this new feature, I need to add a few new columns to existing database tables. After performing these changes on my development server and implementing the new features, what's the easiest way to perfo...

SQL Server Index - Any improvement for LIKE queries?

We have a query that runs off a fairly large table that unfortunately needs to use LIKE '%ABC%' on a couple varchar fields so the user can search on partial names, etc. SQL Server 2005 Would adding an index on these varchar fields help any in terms of select query performance when using LIKE or does it basically ignore the indexes and d...