Skip to content

Tag: sql-server

Using ISNULL when adding NULL to varchar

Whilst experimenting with MSSQL I came across some behaviour I cannot explain. I was looking at what happens to a NULL value when it is added to a varchar, and when I do the following query: I get the result ‘te’. Similarly if I change the word test for any other word I only get the first two lett…

How can I connect C# with Db with App.config?

I need to connect C# with SQL Server database using app.config. My code is: and in app.config I have: but I get an error and I can’t fix it: ConfigurationErrorExeption was Unhandled Configuration system failed to initialize Can anyone help me please ? Answer Try: You’re referencing Conn as the con…

How to round this in SQL

we just started our studying on SQL and I seem to have a slight problem with one exercise. I would need to round the result of I was trying to do it with subquery but I just did not hit the correct one even tough similar subqueries with only select seem to work well. Any help? Answer Use ROUND

Replace identity column from int to bigint

I am using SQL Server 2008, and I have a table that contains about 50 mill rows. That table contains a primary identity column of type int. I want to upgrade that column to be bigint. I need to know how to do that in a quick way that will not make my DB server unavailable, and will not delete

Export data from a non-normalized database

I need to export data from a non-normalized database where there are multiple columns to a new normalized database. One example is the Products table, which has 30 boolean columns (ValidSize1, ValidSize2 ecc…) and every record has a foreign key which points to a Sizes table where there are 30 columns wi…

Calling Functions in SqlCommand

Can I use Sql Server functions in myCommand.CommandText and why? Answer If you mean, SQL Server user defined functions. Then, yes; you can use it normally like: The reason it works is because this is the way that functions are called in SQL Server directly.