Tuesday, September 3, 2013

[SQL Server 2008 issues] How to update string based on Dates.

[SQL Server 2008 issues] How to update string based on Dates.


How to update string based on Dates.

Posted: 02 Sep 2013 06:40 PM PDT

Create Table #temp( Lnno varchar(15), Inst_Date Datetime , Amount Numeric(12,2) ) Create Table #temp1( Lnno varchar(15), No_of_Month Int, Date_Pattern varchar(15), ) Insert Into #temp Values ('1','2013-01-01',1000), ('1','2013-02-15',2000), ('1','2013-03-15',2000), ('1','2013-04-15',2000), ('1','2013-05-15',2000), ('2','2013-02-15',2000), ('2','2013-03-15',2000), ('2','2013-04-15',2000), ('2','2013-05-15',2000), ('2','2013-06-15',2000) Insert Into #temp1(Lnno,No_of_Month) Values ('1','4'),('2','2') Select * from #temp Select * from #temp1 /* Hi, Above are the two table, Now my requirement is,I want to update in table #temp1, Date_Pattern a Date string based on No_Of_Months, For eg, In #temp For Lnno = 1,there are 4 records,and it consist of Inst_Date. So for,Lnno = 1,In Table #temp1 if No_of_Month = 4, then In Date_pattern column , it should be update as 'Jan/Feb/mar/apr' based on the Inst_date in #temp table. So for,Lnno = 2,In Table #temp1 if No_of_Month = 2, then In Date_pattern column , it should be update as 'Feb/mar' based on the Inst_date in #temp table.Please help me.Thanks in Advance!! */

Shrink the database only upto its initial size which is set

Posted: 02 Sep 2013 05:21 PM PDT

I have some database which are already created which are already created with default initial size. But i want to reset the initial size of these. I did it using SSMS.But now if i shrink the database it will shrink beyond the initial size i have set.It will shrink till the initial size it had during creation of database. But i don't want it. I was expecting to shrink till the initial size which i have set.So please suggest me how it can be done?

Updating using # table

Posted: 02 Sep 2013 01:20 AM PDT

Please help me to update the columns using a temp table by using inner join for a set of tables say, activity, activitytype, activitycategoryand left join to update another set of columns, so that the effect of left join does not effect the correctness of values in these columns updated.An example will be handy.

UNION or UNION ALL?

Posted: 02 Sep 2013 05:18 PM PDT

Is it better to use union or union all for combining two select statement queries..??I am checking a SP where some one has written UNION in it..I am not sure whether it will be a bottleneck or not.

Error log in eventvwr

Posted: 02 Sep 2013 02:22 PM PDT

Hi friends,Am receiving the below log in eventvwr. Why am I getting this log? Please help me to get rid off this problem..[b]BobMgr::GetBuf: Sort Big Output Buffer write not complete after 60 seconds.[/b]Thanks in advance..

Please help with a Trigger

Posted: 02 Sep 2013 01:53 AM PDT

Hi There,I have just joined this great forum.I have a question regarding Triggers plsI have a table dbo.Levels and I need to track a start and end date of each level? I have 3 levelsLevel 1, Level 2 and level 3? and the level is pull or I need it to match the actual level from another column within a table called dbo.maincaseany help would be much appreciatedThank youAbdel

sql 2012 dumps

Posted: 01 Sep 2013 08:22 PM PDT

Can any one send the sql 2012 dumps for getting the certified ?

Match Varbinary(max) with another Varbinary(max)

Posted: 02 Sep 2013 12:34 AM PDT

i have a table with one binary column. that contains 0x00010100000101010101......00 column datalength is 35040, i am prepare this data like@Jobbyte = COALESCE(@Jobbyte , 0x) + Cast ((Case When Sum(A.bit) >= 1 then 1 else 0 end)as binary(1))i have to compare this binary data with another binary data and get the matching binary count. both the binary data has equal length of dataPlease look below image, their is 2 binary data Binary1 and Binary2 i want to compare both binary data and get Sum of matching binary data. only one condition is when binary2's single bit is 0x01[img]http://i.stack.imgur.com/WWGI7.png[/img]Last Row is indicate 0 = No Match, 1 = Match and last column is Sum of Last row (4) Please suggest me how can i compare , it's better if you can post a query

uri format error in ssis 2008 R2 script task

Posted: 01 Sep 2013 10:17 PM PDT

Hi,I need to get the latest file from sharepoint. To get the file names in array, I am using the below code in script task string[] files = System.IO.Directory.GetFiles(@"my sharepoint link");But this line is giving me error. Yhe error is below:Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: URI formats are not supported. at System.IO.Path.NormalizePathFast(String path, Boolean fullCheck) at System.IO.Path.NormalizePath(String path, Boolean fullCheck) at System.IO.Path.GetFullPathInternal(String path) at System.IO.Directory.InternalGetFileDirectoryNames(String path, String userPathOriginal, String searchPattern, Boolean includeFiles, Boolean includeDirs, SearchOption searchOption) at System.IO.Directory.GetFiles(String path, String searchPattern, SearchOption searchOption) at System.IO.Directory.GetFiles(String path) at ST_eebeeafd4d024485b0d5d21101efb47b.csproj.ScriptMain.Main() in <some path>:line 47 --- End of inner exception stack trace --- at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture) at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()The same code is running fine if I give local system path or some network disk path. I can understand from the above error that I need to use some reference to system.web, but I need help here.Please help me in resolving this issue.ThanksRajneesh

No comments:

Post a Comment

Search This Blog