Showing posts with label feature. Show all posts
Showing posts with label feature. Show all posts

Monday, March 26, 2012

Import from MySQL db adds padding in CHAR (Text) fields

I'm moving a small application from a MySQL db to MSSQL2K and using the Import feature of SQL2K. The db in question is simple, only three tables, mostly text (CHAR) fields. The problem is that when I examine the field contents I find that the unused cha
racter positions within the fields have been padded with trailing spaces. (Example: original 10 char field containing "ABC" now contains "ABC ". Application not happy. I've tried a number of options in the Import wizard (ansi padding etc) and it
seems to have had no effect. Any ideas? Solutions? KB articles?
Thanks for ANY help.
-J
By definition, a char(10) is always padded with spaces up to the length of the datatype. This is why we call
char a fixed length datatype. If you want a variable length datatype, use varchar.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"JManton" <anonymous@.discussions.microsoft.com> wrote in message
news:D89560CC-AAAB-459C-A039-8073C17EB2ED@.microsoft.com...
> I'm moving a small application from a MySQL db to MSSQL2K and using the Import feature of SQL2K. The db in
question is simple, only three tables, mostly text (CHAR) fields. The problem is that when I examine the
field contents I find that the unused character positions within the fields have been padded with trailing
spaces. (Example: original 10 char field containing "ABC" now contains "ABC ". Application not happy.
I've tried a number of options in the Import wizard (ansi padding etc) and it seems to have had no effect.
Any ideas? Solutions? KB articles?
> Thanks for ANY help.
> -J
|||That was it. I guess there are a few diffs between MySQL and MSSQL. I also had to tweak the recordID field and use IDENTITY attribute. Thanks for the quick reply and on-the-mark-help.
-J

Import from MySQL db adds padding in CHAR (Text) fields

I'm moving a small application from a mysql db to MSSQL2K and using the Impo
rt feature of SQL2K. The db in question is simple, only three tables, mostl
y text (CHAR) fields. The problem is that when I examine the field contents
I find that the unused cha
racter positions within the fields have been padded with trailing spaces. (E
xample: original 10 char field containing "ABC" now contains "ABC ".
Application not happy. I've tried a number of options in the Import wizar
d (ansi padding etc) and it
seems to have had no effect. Any ideas? Solutions? KB articles?
Thanks for ANY help.
-JBy definition, a char(10) is always padded with spaces up to the length of t
he datatype. This is why we call
char a fixed length datatype. If you want a variable length datatype, use va
rchar.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"JManton" <anonymous@.discussions.microsoft.com> wrote in message
news:D89560CC-AAAB-459C-A039-8073C17EB2ED@.microsoft.com...
> I'm moving a small application from a mysql db to MSSQL2K and using the Import fea
ture of SQL2K. The db in
question is simple, only three tables, mostly text (CHAR) fields. The probl
em is that when I examine the
field contents I find that the unused character positions within the fields
have been padded with trailing
spaces. (Example: original 10 char field containing "ABC" now contains "ABC
". Application not happy.
I've tried a number of options in the Import wizard (ansi padding etc) and i
t seems to have had no effect.
Any ideas? Solutions? KB articles?
> Thanks for ANY help.
> -J|||That was it. I guess there are a few diffs between mysql and MSSQL. I also
had to tweak the recordID field and use IDENTITY attribute. Thanks for the
quick reply and on-the-mark-help.
-J

Import from MySQL db adds padding in CHAR (Text) fields

I'm moving a small application from a MySQL db to MSSQL2K and using the Import feature of SQL2K. The db in question is simple, only three tables, mostly text (CHAR) fields. The problem is that when I examine the field contents I find that the unused character positions within the fields have been padded with trailing spaces. (Example: original 10 char field containing "ABC" now contains "ABC ". Application not happy. I've tried a number of options in the Import wizard (ansi padding etc) and it seems to have had no effect. Any ideas? Solutions? KB articles?
Thanks for ANY help.
-JBy definition, a char(10) is always padded with spaces up to the length of the datatype. This is why we call
char a fixed length datatype. If you want a variable length datatype, use varchar.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
"JManton" <anonymous@.discussions.microsoft.com> wrote in message
news:D89560CC-AAAB-459C-A039-8073C17EB2ED@.microsoft.com...
> I'm moving a small application from a MySQL db to MSSQL2K and using the Import feature of SQL2K. The db in
question is simple, only three tables, mostly text (CHAR) fields. The problem is that when I examine the
field contents I find that the unused character positions within the fields have been padded with trailing
spaces. (Example: original 10 char field containing "ABC" now contains "ABC ". Application not happy.
I've tried a number of options in the Import wizard (ansi padding etc) and it seems to have had no effect.
Any ideas? Solutions? KB articles?
> Thanks for ANY help.
> -J

Sunday, February 19, 2012

Impliment MySQL LIMIT command on SQL Server

Hi there, it seems the search feature refuses to work so i am posting a question which I am sure has been answered :)

What is the best way to get the LIMIT command functionality in SQL SERVER?

I am making an ASP.NET page, and am unsure how to go about tabbing through 100s of results.

Many thanks,
TazSql Server does not have a LIMIT functionality. You can either use TOP to only select the TOP n records, or implement your own paging.|||BTW: In .NET, you can implement paging through a .NET control. Performance isn't as good as building your own paging, but if you don't want to go through the trouble, it's worth looking into.|||Use SQL Server 2005? The LIMIT clause shouldn't be implimented in a relational database, even though it is quite convenient. In SQL 2005, Microsoft chose to implement this functionality due to user demand in spite of the fact that it limits the design of the database engine in other ways.

-PatP|||the SQL server equivalent of MySql LIMIT is TOP

MySQL
select * from MyTable LIMIT 10

SQL Server
select TOP 10 * from MyTable|||the SQL server equivalent of MySql LIMIT is TOPSo, where does the comma go?

While you are correct that the TOP predicate implements part of what LIMIT does in MySQL (i.e. the first parameter), it does not handle the paging portion (when there are two parameters). Paging result sets has no set based solution (because it is both stateful and sequence dependant), so it really should be implemented via an N-tier solution.

-PatP|||Right Pat. TOP is only a closest equivalent in Sql2K and having Limitations compared to MySql LIMIT.|||Please remember that both limit and top are dangerous if not paired with some order by's. Without that control, a relational DB is free to return records in any order it feels like.