Quote:
Originally Posted by
blackrageous
I gather you are using the sqlcmd client on the UNIX side. The sqlcmd -v switch (at least on the dos version is for the purpose of passing variables into the embeddeded SQL input file.
Please confirm that you are running sqlcmd on unix. If so what operating system / version of Unix?
HI Blackrageous,
Yes, I am passing the date variable through unix. We are using Linux version.
I am able to pass the variable but still will need suggestions in case of improvements.
- passed the date while executing the shell as a argument.
- Checked whether the date is passed or else moved the environment variable which contains a date in format yyyy-mm-dd. THis will go into variable_passed_date1 local variable
- used the export variable command for variable passed_date1.
Now, I am able to use varaiable_passed_date1 in the input SQLCMD sql file.
- Also, in the SQL server SP, I have defined the argument as datetime and using the CONVERT function to convert it into YYYY-mm-dd HH:MM:SSS (something of this format).
This is working, but the HH:MM:SS.SSS is 0 and I want it to be set as a high value so that all records of the particular date are captured.
---------- Post updated at 11:33 PM ---------- Previous update was at 11:31 PM ----------
Quote:
Originally Posted by
DGPickett
Usually, you choose a string format that is compatible, as passing binary date-time is a compiled code deal, not scripting. I like "YYYY-mm-dd HH:MM:SS.ssssss" but your SQL engine may vary. Sometimes you need a conversion tool like a CONVERT() function.
Thanks for the reply!
I have declared the date variable as date and later converting it into datetime using CONVERT. This is working fine now.