.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How do I suppress the creation of nchar(), nvarchar()

Posted By:      Posted Date: September 02, 2010    Points: 0   Category :Sql Server
Some of the wizards and import tools that create tables use nchar() and nvarchar() for character fields. Also the upgrade wizard from Access does the same thing. Is there a way to prevent the creation of nchar() and varchar() fields and to use char() and varchar()? Is there some TSQL I can use to pass over the exisitng tables and conver the datatypes?

View Complete Post

More Related Resource Links

What is the Difference Between nchar(n) and nvarchar(n)?


Hi, What is the difference between these two data types in SSCE 4.0:

nchar(n) and nvarchar(n)

The documentation here states for nchar(n):

Fixed-length Unicode data with a maximum length of 4000 characters. Default length = 1. Storage size, in bytes, is two times the number of characters entered.

and for nvarchar(n):

Variable-length Unicode data with a length of 1 to 4000 characters. Default length = 1. Storage size, in bytes, is two times the number of characters entered.

I presume by "number of characters entered" it is meant "number of characters stored for the column value in the table row". But if that is true, it is not clear to me how nchar is "fixed-length", nor how it is different to nvarchar.

Any help with this would be much appreciated.

Many thanks.

Regards Martin


Need help regarding C# / AJAX Dynamic Controls creation


radiobuttons is assigned before page init.. 

public partial class Default : System.Web.UI.Page
//Assign values as a specific Dynamic WebControl Creation.
List<RadioButton> radioButtons = new List<RadioButton>();
List<CheckBox> checkBoxes = new List<CheckBox>();

Then I created a class that would dynamically create a table containing the available flights depending on session.. (See CallPageLoad())

The placeholder and button is inside the UpdatePanel...

on the button inside the update panel, (btnSelect)

i have this code which works... 

protected void btnSelect_Click(object sender, EventArgs e)

Label1.Text = Convert.ToString(radioButtons.Count);

It detects the number of radiobuttons that were dynamically created...

But when I use the following code inside the BtnSelectClick event...

//PLS HELP.......
foreach (RadioButton button in radioButtons)
if (button.Checked == true)
Label1.Text = "You select... " + button;



It does not work even though t

Bug: Does not change column type from nvarchar to ntext


Scenario: If you create a table with a column of type nvarchar, populate it with some content and try to modify it using the WebMatrix editor, from nvarchar to ntext, it does not display any error message or warning that this is not possible. It silently saves and reverts the change, back to nvarchar. Wasted some hours on this issue as I thought my column was ntext, but in fact was still nvarchar.

Expected behavior: It should change to ntext, or if SQL CE doesn't support that, it should notify the user that no change was applied.

I need help about nvarchar field



how can specified nvarchar data type without N''?

SQL/MTS: Automating the Creation of COM+ Components for a Database Schema


Using Microsoft Windows DNA architecture as a guideline, it's possible to create scalable multitier database applications with COM+ and Microsoft Transaction Services. In fact, you can use existing table definitions to automatically build the MTS/COM+ business logic layer and data access components for your application. This article will walk you through the development of database transactions by mapping the transactions to automatically generated MTS/COM+ components. This technique can greatly simplify the task of creating components for a large project.

Aleksandr Mikunov

MSDN Magazine July 2000

Association creation error


In the dbml Designer surface in VS2010, I am associating two views from a database which I am only granted for View access. 

The View1 has 
  Site (smallint, not null)
  LocationID (int, not null)

The View2 has
  Site (int, not null)
  LocationID (int, not null)

Due to the incompatible types between this two, the association can not be created.  Is there other way to create the association, such as cast(View1.Site as int) in the assocation?

MySite creation never completes

Our moss 2007 SP2 farm currently won't create any My Sites.  When a new user visits my.domain.com they get the "Please wait while your personal site is setup for the first time and the default document libraries and lists are created.  This may take several seconds." message but it just sits there forever.

I'm not sure when it stopped working as we only really create new accounts at certain periods during the year - it was working 6 months ago.

I can't find any log messages about the creation/failure - any tips on where to look?


Suppress postback on ImageButton


I have the following JavaScript defined for the OnClientClick event of an ImageButton:

var _oHasChanged = $get(_chkHasChanged); if (_oHasChanged && _oHasChanged.checked) { alert('De gewijzigde gegevens moeten worden opgeslagen alvorens deze actie kan worden uitgevoerd.'); return false; }

As you can see, I have "return false;" after the alert, because I don't want a postback in that situation.

This is working just fine in Firefox, but Internet Explorer seems to ignore the "return false;" bit and posts back to the server anyway.

What am I missing here?

User creation, authenication


 What is the best approach to allowing users to create accounts and allow them to login later?

am thinking of passing all the user information into an attached SQL database, so that when users login l can lod their profilee and allow them to add data on their profile.

is there an easy way to this? can someone provide me a good sample code?


Thank you for your help in advance


Why does .NET Framework 4 client profile slow down boot time network creation?

I've been running a Windows XP sp3 KVM virtual machine for a long time now, and some recent update made the initial network startup go from a few seconds at boot time to around 90 seconds. Using Add/Remove program to uninstall recent updates points the finger at .NET Framework 4 client profile. With it installed, if I right click on network and ask for properties right after booting, there is a 90 second delay before the network dialog with the list of network interfaces finally appears. In addition, the network drive I have automounted at login is not accessible for the same 90 seconds. As an experiment, I tried going into the device manager and deleting the network interface, and if I reboot after that it takes 90 seconds for the new hardware wizard to appear. All these 90 second delays vanish if I remove this .NET update. The network comes up as soon as the system boots.

Suppress Blank Rows in Grouping on SRS

I have a Table on a SRS report.  Within that Table I have a Group. I display Rows from the DataSet in the Group Header.  In the Detail Line of the Group, I display rows if a condition is true.  That condition is in the Filter Criteria (Fields!GroupID.Value > 0).  If the GroupID equals 0, I want to suppress the detail line.  If GroupID is greater than 0, I want to show it.  This works great in development mode within Visual Studio 2005. I deploy to SRS on our Test Server and run the report. All of the detail rows are displayed even the ones where GroupID = 0. I am using the same Data Source.  The only difference is running the report within Visual Studio and the SRS web site. Does anyone have a suggestion.  

Conversion Failed when Converting the nvarchar value 'N' to data type int.

Hi.. I am facing a strange situation. when i executing the following query it is returning the error SELECT  s.row_id as shipment,    SUM(CAST(la5.attr_value AS INT)) AS Cases     FROM    shipment s WITH(NOLOCK)    INNER JOIN shipping_shift ss WITH(NOLOCK) ON s.shipping_shift = ss.row_id    INNER JOIN shift WITH(NOLOCK) ON ss.shift_id = shift.shift_id    INNER JOIN shipment_lot sl WITH(NOLOCK) ON s.po_id = sl.po_id AND s.cust_id = sl.cust_id AND          s.so_line_no = sl.so_line_no and s.ship_date_local = sl.ship_date_local     INNER JOIN lot_attr la5 WITH(NOLOCK) ON sl.lot_no = la5.lot_no AND sl.item_id = la5.item_id AND la5.attr_id = (SELECT attr_id FROM attr WITH(NOLOCK) WHERE attr_desc = 'CaseQty' AND attr_grp = 3)  WHERE s.spare2 = 'RELEASED'       AND shift.shift_desc = 'c'   AND DAY(ss.production_date) = DAY('2010-08-09 00:00:00.000')    AND MONTH(ss.production_date) = MONTH('2010-08-09 00:00:00.000')    AND YEAR(ss.production_date) = YEAR('2010-08-09 00:00:00.000') GROUP BY s.row_id  Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the nvarchar value 'N' to data type int. The column  type of attr_value of lot_attr table is a USER D

How to store binary data as nvarchar(max)?

I’m trying to store a blob of binary data as nvarchar(max) and it gets truncated after just a few bytes. I wonder why and how can I prevent it. I don’t use varbinary(max) because I’m trying to keep existing DB schema intact. Current DB contains a huge chunks of text in nvarchar(max) column and I’m trying to compress (zip) this text and store it back to the same field to reduce DB size.   DB is accessed using Sync Framework (and Entity Framework) on the client side, so actual DB engine is SQL Server Compact 3.5 SP2   Thank you! KonstantinThank you! Konstantin

SQL Database Creation Path

Declare   @Path as varchar(500); Declare @mdfpath as varchar(500); Declare   @ldfpath as varchar(500); Set   @Path=(SELECT SUBSTRING(physical_name, 1,CHARINDEX(N'master.mdf',LOWER(physical_name)) -21) DataFileLocation FROM master.sys.master_files WHERE database_id = 1 AND FILE_ID = 1) set   @mdfpath=@Path+'\MSSQL.1\MSSQL\DATA\jjjj3.mdf'; set   @ldfpath=@Path+'\MSSQL.1\MSSQL\DATA\jjjj3_log.ldf';     CREATE DATABASE [jjjj3] ON PRIMARY ( NAME = 'jjjj3', FILENAME = @mdfpath , SIZE = 2048KB , FILEGROWTH = 1024KB )   LOG ON (   NAME = 'jjjj3_log', FILENAME = @mdfpath , SIZE = 1024KB , FILEGROWTH = 10%) The Above procedure creation error b'use of dynamic path of SQL, How to select Dynamic path to file name Thanks K. Govindaraj

Automating Gmail Account Creation

I tried to remove some unnecessary thing like styles but the HTML is still lengthyBelow is the source of: https://www.google.com/accounts/NewAccount?service=mail<html> <head> <title>Google Accounts</title> </head> <body onLoad="return(doKtInit());" > <script type="text/javascript"> var KT_keydownHandler,KT_keypressHandler,KT_logEncoder,KT_lastElement=-1,KT_lastKeyCode=-1,KT_lastModifiers=-1,KT_logElement=0,KT_stoppedLog,KT_ALLOW_FIELD_TYPES={password:1,text:1},KT_ALLOW_FIELD_IDS={firstname:1,lastname:1,email:1,passwd:1,passwdagain:1,identityanswer:1,secondaryemail:1,newaccountcaptcha:1,nickname:1},KT_lastTime,KT_inputs,KT_keyInputs=[];if(window.captureEvents){Event.KEYPRESS&&window.captureEvents(Event.KEYPRESS);Event.KEYDOWN&&window.captureEvents(Event.KEYDOWN)} function KT_preSubmit(){if(KT_logEncoder){if(KT_keydownHandler){KT_encode(16);KT_initHandlers(KT_inputs)}var a=KT_logEncoder;if(a.d!=0){EN_encodeGroup(a,a.p);a.p=0}}}function KT_encode(a){a<0?KT_stopLog():EN_encode(KT_logEncoder,a)}function KT_init(a,c,d){a=KT_logElement=a;if(!a.value)a.value="A";KT_logEncoder={e:a,p:0,d:0};KT_initHandlers(d);c=c;if(!c.value)for(d=1;d<KT_keyInputs.length;d++)c.value+=KT_keyInputs[d].name+" "} function KT_event(a,c){if(KT_logElement.value.length>3E3){KT_encode(17);KT_stopLog

can i use nvarchar(300) for a column having records as website links?

Hi guys, small question. is it good to use nvarchar(300) for a column having records as website links. i was told the size may exceed 255 characters. so just thinking is it possible?

Need suggestion on table creation

Hi All    I want to create a DB in production server. In the DB 5 tables will consists lakhs of records.    We are using SQL Server 2005 Enterprise Edition    To produce the better performance i want to create 5 Data Files for 5 tables.Is my approach is    right or wrong.    Waiting  for valuable replies.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend