sql-server

Database modeling tool

I am looking for a simple tool to draw up my database in. I know that i saw one that was made in C# on Codeproject but i can't find that one. I just need to be able to visually draw my tables and relations for MS SQLServer 2008. ...

Is there meta data I can read from SQL Server to know the last changed row/table?

We have a database with hundreds of tables. Is there some kind of meta data source in SQL Server that I can programatically query to get the name of the last changed table and row? Or do we need to implement this ourselves with fields in each table called LastChangedDateTime, etc.? ...

SQL Server 2008 - Bulk Insert a whole text file into one field

I have a text file (txt) containing formatted text (just line breaks, carriage returns and tabs) It also contains German language characters. I want to use the Bulk Insert comment in T-SQL to read in the text file into one field within a database table. I ran this command: CREATE TABLE #MyTestTable ( MyData NVARCHAR(MAX) ) BUL...

How do I add months to a CURRENT_TIMESTAMP in SQL?

How can I add months to the CURRENT_TIMESTAMP in SQL Server? The solution probably lies in DATEADD() but this works with a date only, not a datetime. Thanks. ...

C# Report Wizard and Entity Framework.

This is probably quite simple, but I just don't know how to do this... I have a reasonable complex SQL Server database containing multiple schema's for data and a generic view to provide information over all those views. (Basically, it lists all extended properties of all schema's.) This setup cannot be changed since every schema is spe...

How to prevent CAST errors on SSIS ?

Hello, The question Is it possible to ask SSIS to cast a value and return NULL in case the cast is not allowed instead of throwing an error ? My environment I'm using Visual Studio 2005 and Sql Server 2005 on Windows Server 2003. The general context Just in case you're curious, here is my use case. I have to store data coming from ...

Saving LINQ-to-SQL Transactions to Re-Run Later?

Hi Guys I wrote a an application for configuring a platform we have. Our current process is make the configuration changes in a staging environment and when they're approved, make the same changes in a production environment. There's room for error in this process in that there's a risk that the user might mistakenly make a change in ...

List ms sql data in vb.net

I got no errors in the code now, but it doesn't seem to work. The only thing that works is when I try to list all the data. But when I try to narrow the data that is to be listed. I get no good results. Here is my code: If ComboBox1.SelectedItem = "School" Then Dim connectionString As String = "Data Source=SENBONZAKURA\SQL...

T-SQL: Displaying data from multiple columns into one output column using CASE and COALESCE

I have the following SQL code that runs against a Change Request database. Each record has several columns that represent affected US regions. If the change affects a region the value will be 1 otherwise NULL. So I am adding the values in each column to determine if more than one region is affected, the answer will be greater than 1. ...

How can convert 15000000.00 to 15,000,000 in SQL server?

There is a one value 15000000.00 with Numeric datatype in SQL server. How can i get or convert the value 15000000.00 to 15,000,000? ...

SQL Server 2008, join or no join?

Just a small question regarding joins. I have a table with around 30 fields and i was thinking about making a second table to store 10 of those fields. Then i would just join them in with the main data. The 10 fields that i was planning to store in a second table does not get queried directly, it's just some settings for the data in the ...

SQL Server 2000 incorrect message: duplicate key with unique index

Database server: SQL Server 2000 - 8.00.760 - SP3 - Standard Edition I have a table with 5 columns, in which I want to add a large (300.000) number of records. There is a unique index on the combination of two columns. If I add the records with this unique index in place, SQL Server gives this error message: Msg 2601, Level 14, Stat...

How to select all parent objects into DataContext using single LINQ query ?

I am looking for an answer to a specific problem of fetching whole LINQ object hierarchy using single SELECT. At first I was trying to fill as much LINQ objects as possible using LoadOptions, but AFAIK this method allows only single table to be linked in one query using LoadWith. So I have invented a solution to forcibly set all parent ...

TransactionScope and Connection Pooling

Hi, I'm trying to get a handle on whether we have a problem in our application with database connections using incorrect IsolationLevels. Our application is a .Net 3.5 database app using SQL Server 2005. I've discovered that the IsolationLevel of connections are not reset when they are returned to the connection pool (see here) and ...

How would you make a "Favorite Pages" system

So I was asked by my management to incorporate a way for users to mark pages in my website as "favorite" and have them show up in a special list. This site has a static structure (I do not generate pages). I am wondering about the best way to do that. My first thought was to store it in the database (since user information is also sto...

in sql server check the string contains particular values

@Phoneno varchar @Phoneno='(123)(4520)' how to check if @ Phoneno doesnt have number with in the arrow brackets? example @Phoneno='()()' ...

SQL 2000 - Execute process task - doesn't run exe

Hi, I am currently developing completely on a local machine and have a DTS package that on completion should run a local exe file that compresses the csv files that were just imported. If I run the package in the designer or from the list of packages then all is fine and the files are compressed. If I run the file from SQL Agent as a ...

CTE with dynamic query

I have a dynamic query which I call and I put the Result set in a variable table INSERT INTO @outTable EXEC sp_executesql @query; The problem is that @outTable should change When adding column in @query - @query is another stored procedure. I tried to use a CTE (WITH), but it does not work with EXEC. Is this possible do to in T-SQ...

Sync Framework: Can I syncronise Stored Procedure

Does the sync framework allow me to synchronise (download only) the Store Procedures on a sql server 2008 server with the Stored procedures on the SQL Server 2008 client? i.e. overwrite the SP on the client when the server SP's have been modifed or new ones created? Thanks ...

Programmatically creating linked tables in access

Hi all, We need to find a way to programatically *link all the tables* in a SQL Server database to an access db. We will be invoking this access database from a program that uses .net/SQL Server 2008. While invoking the application we would like to add the linked tables so that the users can just run the reports/modules from access with...