SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 question on field lengths
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kowalsky
Starting Member

USA
29 Posts

Posted - 09/05/2013 :  17:35:07  Show Profile  Reply with Quote
hi all,
i didn't think this thru', nevertheless, here is my question:
I have a table in a development database with nvarchar fields. Most of them are nvarchar(50). Later on, in the QA environment, a new copy of the database was created and the table has the same fields but the lengths have been modified to correspond to the actual lengths of the source data fields. Most of the time the lenghts are smaller. Is there any way I can insert the data from my development table into the QA table namely, a nvarchar(50) into a nvarchar(4), knowing that the actual length of that field is always 4.

Thanks,
kowalsky

kowalsky
Starting Member

USA
29 Posts

Posted - 09/05/2013 :  17:47:48  Show Profile  Reply with Quote
I believe one way could be to have a conversion before the insert:
insert into tableQA(fld1, fld2)
select CONVERT(nvarchar(4), fld1) as fld1, CONVERT(nvarchar(10), fld2) as fld2 from tableDEV

Is there any other way?

Thanks,
kowalsky

kowalsky
Go to Top of Page

LoztInSpace
Aged Yak Warrior

940 Posts

Posted - 09/06/2013 :  01:26:15  Show Profile  Reply with Quote
You could just do the straight insert and SQL Server will about if you have longer data than will fit. Other than that, not really othe rthan select LEFT(fld1,4) type of thing.

Now go and fix your development database so it represents the actual database before you get into any more trouble ;) !!
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000