BIGINT scalar function [closed] - tsql

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
How to??
Create a scalar function that returns a bigint.
The function takes 2 inputs of bigint.
The function multiplies the inputs and returns the result.
Thank You,

How about something like this:
CREATE FUNCTION [dbo].[testbigint]
(
#int1 bigint,
#int2 bigint
)
RETURNS bigint
AS
BEGIN
-- Declare the return variable here
DECLARE #returnVal bigint
set #returnVal = #int1* #int2
-- Return the result of the function
RETURN #returnVal
END

Related

Count the number of words for each contributor [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
How can I count the number of words that each contributor wrote in a repository ?
It is best solved on a local clone of that GitHub, in order to analyze the git log and check each contributor.
See "getting contributor stats", based on:
git log --author="Jared Barboza" --pretty=tformat: --numstat | \
grep -v public/javascripts/jquery | \
gawk '{ add += $1 ; subs += $2 ; loc += $1 - $2 } END \
{ printf "added lines: %s removed lines : %s total lines: %s\n",add,subs,loc }' -
But that is for lines added/removed for a given contributor.
(a bit like in "Git: How to estimate a contribution of a person to my project in terms of added/changed lines of code?")
You can combined a similar approach with the one described in "Quantifying the amount of change in a git diff?".
Or you can use a dedicated program for that, like git-wordcount.

Convert a mixed string to UTF16 with PHP [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have a string in PHP like this:
INPUT = "Γιώργο αν στείλεις αυτό ακριβώς (:
Its a mixed string with GREEK and LATIN characters at the same time. I want all characters in a given string to be converted to this string
OUTPUT = 0022039303B903CE03C103B303BF002003B103BD002003C303C403B503AF03BB03B503B903C2002003B103C503C403CC002003B103BA03C103B903B203CE03C200200028003A
How can I convert the input to this kind of output?
It took me a while to figure out but it seems that what you want to do is to convert a UTF-8 string to an uppercase binary dump of its UTF-16 representation. It's as simple as this:
$input = '"Γιώργο αν στείλεις αυτό ακριβώς (:';
$output = mb_strtoupper(bin2hex(mb_convert_encoding($input, 'UTF-16BE', 'UTF-8')));
The BE suffix indicates Big Endian, which seems to be the expected byte order according to your example.
Have you tried iconv? Maybe something like this:
(EDIT) i understand your main goal is to be able this converted string to be transported via http to your service, in that case you can use base64_encode() on the result.
see the complete code example:
<?php
$string = str_replace(' ', '', "Γιώργο αν στείλεις αυτό ακριβώς");
$converted = iconv('UTF-8', 'UTF-16', $string);
$encoded = base64_encode($converted);
var_dump($encoded);
var_dump(iconv('UTF-16', 'UTF-8', base64_decode($encoded)));
?>
You will get:
encoded: string '/v8DkwO5A84DwQOzA78DsQO9A8MDxAO1A68DuwO1A7kDwgOxA8UDxAPMA7EDugPBA7kDsgPOA8I=' (length=76)
decoded: string 'Γιώργοανστείλειςαυτόακριβώς' (length=54)

How to compare two dates using UNIX commands [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have dates like this
Date1="Wed Oct 21 13:05:14 2012"
Date2="Wed Nov 21 12:55:30 2010"
Date3="Wed Nov 21 14:22:30 2012"
How do I find out the latest date?
The unix date command can convert date formats, see for example here. So in bash, you'd do something like this:
#!/bin/sh
Date1="Wed Oct 21 13:05:14 2012"
Date2="Wed Nov 21 12:55:30 2010"
Date3="Wed Nov 21 14:22:30 2012"
ts1=`date -d"${Date1}" +%Y%m%d%H%M%S`
ts2=`date -d"${Date2}" +%Y%m%d%H%M%S`
ts3=`date -d"${Date3}" +%Y%m%d%H%M%S`
latest=ts1
if [ $ts2 -gt $ts1 ]; then
latest=ts2
fi
if [ $ts3 -gt $ts1 ]; then
latest=ts3
fi
echo "Latest date is ${latest}"

add an option to the perl script command line [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
assume this is file.txt
Name:Lab1:Lab2:Lab3:Lab4:Lab5:Lab6:Exam1:Exam2:Final
Annette Adams :8:24:19:24:10:12:43:35:98
Mary Beard:9:30:19:23:10:14:29:39:87
Antoinette Brown:9:16:18:22:9:12:19:31:79
.
.
.
is it possible in Perl to write a script with some options which user can pass to command line and get the result.
for example getAverage.pl -l 3 file.txt prints the average of Lab3 Marks.
if it is possible what is the overall process?
Try http://perldoc.perl.org/Getopt/Long.html From the documentation:
The Getopt::Long module implements an extended getopt function called
GetOptions(). This function adheres to the POSIX syntax for command
line options, with GNU extensions. In general, this means that options
have long names instead of single letters, and are introduced with a
double dash "--". Support for bundling of command line options, as was
the case with the more traditional single-letter approach, is provided
but not enabled by default.
For general information about accessing command line options in Perl, read the perlvar documentation: http://perldoc.perl.org/perlvar.html#$ARGV
I put together a quick and dirty solution in python. Should be easy to port it to perl.
import sys
lines = open("file.txt",'r').readlines()
if len(sys.argv) > 2 and sys.argv[1] == "-l":
try:
number = int(sys.argv[2])
except:
print "Input a number after the -l switch."
average = 0
for i in lines:
try:
average += int(i.split(":")[number])
except:
pass
average /= 3
print "The average score for %s is %d" \
%(lines[0].split(":")[number], average)
else:
print "Computer says no."

IF or CASE or WHILE LOOP. What's the Best approach? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
If it's greater than 10 set the variable to -1 and select that variable output.
If less than 10 select the variable as the output.
DECLARE #i INT
SET #i = 10
SELECT #i = (#i * 10)
Thank You,
Not entirely sure what you're looking for. Does this help?
declare #myResult int
select #myResult = case when #i > 10 then -1 else #i end
print #myResult
you cannot combine a select statement that assigns a value to a variable with an expression that returns data... So you need two statements...
Declare #I Integer = 4
Select #I = Case When #I > 10 Then -1 Else #I End
Select #I