1
vote
1answer
500 views

How can I restore the sql_variant_property of baseType back to a table variable in SQL Server

Ok, I know the title is confusing but here it goes. BTW I am using SQL Server 2008 I have a table that I am trying to use as a storage container. It has 3 columns: reportID integer, dataLabel ...
1
vote
1answer
4k views

Table schema column data type equivalents for Netezza 6 to SQL Server 2008

I'm trying to find a data type equivalents for data types in Netezza when migrating table schema to SQL Server. Where can I find a complete list? When getting down to brass tacks, I am specifically ...
0
votes
4answers
525 views

Writing SQL statement in sqlcmd to hide the milliseconds for column type of time

I have a table called testtable that have a column named expire_time of type [time] The problem is that when I type the following in sqlcmd: select * from testtable It will return the following: ...
0
votes
1answer
424 views

timeout on updating nvarchar(max) after converting datatype

I recently Upgraded to 2008 Enterprise and took the opportunity to change the biggest table in my db with the maintenance window. ran the following to change my ntext field ALTER TABLE ...
4
votes
2answers
765 views

Change column data type across database

I have a bunch of tables with many columns of data type ntext. I wish to change all such columns in all tables of a particular database to nvarchar(max), because of planned deprecation (EDIT: also ...
6
votes
2answers
598 views

What are the pros/cons of splitting date and time into separate fields vs. using the datetime data type and storing the date in a single field?

My database is extremely large and growing at a rate of ~20m rows/day. I have timestamp data that is important but most of the reporting is based on date ranges and week over week or month over month ...
9
votes
1answer
511 views

Why does 10^37 / 1 throw an arithmetic overflow error?

Continuing my recent trend of playing with large numbers, I recently boiled an error I was running into down to the following code: DECLARE @big_number DECIMAL(38,0) = '1' + REPLICATE(0, 37); PRINT ...
2
votes
1answer
93 views

Create a Function in sql server without specifying return_data_type

I am trying to create a Scalar-valued function in SQL server, without specifying the return_data_type i want to be able to return any datatype based on a parameter sent by the function caller e.g. ...
5
votes
2answers
3k views

Data type for storing an array of flags (a bitmap/bit array)

I need to store a bit array for each record of a table, supporting the following operations: Testing if a bit is set, and setting a bit (using SQL) Querying and setting the value using ADO 2.8 (not ...
3
votes
4answers
1k views

Best pratice to store dates group by months-year key par value

I am making one service which needs to hold data grouped and calculated by year-month combination. I know how to calculate data and put it on new table. But I am confused what kind of data type I ...
5
votes
1answer
9k views

Table-Valued Parameter as Output parameter for stored procedure

Is it possibile to Table-Valued parameter be used as output param for stored procedure ? Here is, what I want to do in code /*First I create MY type */ CREATE TYPE typ_test AS TABLE ( id int ...
3
votes
1answer
2k views

Storing XML in varchar(MAX) or use SQL-XML

I am defining a schema for a new set of resources using SQL Server 2008... In this case, each record (e.g. row) will need to store XML fragments. From time-to-time; although not frequently; I'll need ...
2
votes
1answer
4k views

Column size with datatype decimal

According to BOL for SQL Server 2008 R2 the data type decimal requires the following storage bytes: Precision Storage bytes 1 - 9 => 5 10-19 => 9 20-28 => 13 29-38 ...
8
votes
2answers
3k views

Why does “SELECT POWER(10.0, 38.0);” throw an arithmetic overflow error?

I'm updating my IDENTITY overflow check script to account for DECIMAL and NUMERIC IDENTITY columns. As part of the check I compute the size of the data type's range for every IDENTITY column; I use ...
18
votes
7answers
7k views

How do long columns impact performance and disk usage?

In our current project it just happens too often, that we need to extend columns by a couple of characters. From varchar(20) to varchar(30) and so on. In reality, how much does it really matter? How ...