I am new to SQL SERVER and need your advise on something. I have a big table with stores information. Here is bench_id column: **bench_id** 31 51 51 61 61 61 71 71 I have created another small table …
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 to convert a loop in SQL to Set-based logic
I have spent a good portion of today and yesterday attempting to decide whether to utilize a loop or cursor in SQL or to figure out how to use set based logic to solve the problem. I am not new to set logic, but this problem seems to be particularly complex. The Problem The idea is that if I have
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…
Relationship of Primary Key and Clustered Index
Can a TABLE have a primary key without a clustered index? And can a TABLE have a clustered index without having a primary key? Can anybody briefly tell me the relationship between primary key and …
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.
How can I find the dependencies of a multiple objects in sql databases?
sp_depends will provide information for all dependent objects on a particular objects But it is working for only single object , giving information about single object. I want the information about multiple object, How can I achieve it using sp_depend or any other way is there? Answer You want sys.sql_express…